Skip to content

Commit a5111ac

Browse files
Optimized and added flood fill demo
1 parent 559dd1c commit a5111ac

File tree

8 files changed

+353
-272
lines changed

8 files changed

+353
-272
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"rom": "84pce_515.rom",
3+
"transfer_files": [
4+
"bin/DEMO.8xp"
5+
],
6+
"target": {
7+
"name": "DEMO",
8+
"isASM": true
9+
},
10+
"sequence": [
11+
"action|launch",
12+
"delay|300",
13+
"hash|1",
14+
"key|enter",
15+
"delay|300",
16+
"hash|2",
17+
"delay|300",
18+
"key|enter",
19+
"delay|300"
20+
],
21+
"hashes": {
22+
"1": {
23+
"description": "A black star outline is drawn to the screen",
24+
"start": "vram_start",
25+
"size": "vram_8_size",
26+
"expected_CRCs": [ "7EA01B1B" ]
27+
},
28+
"2": {
29+
"description": "The rest of the screen will be filled a solid black",
30+
"start": "vram_start",
31+
"size": "vram_8_size",
32+
"expected_CRCs": [ "4CECC590" ]
33+
}
34+
}
35+
}

examples/gfx_floodfill/makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#----------------------------
2+
3+
#Change TARGET to specify the output program name
4+
#Change DEBUGMODE to "DEBUG" in order to compile debug.h functions in, and "NDEBUG" to not compile debugging functions
5+
#Change ARCHIVED to "YES" to mark the output as archived, and "NO" to not
6+
#Change ICONPNG to change the name of the png file that should be made into the icon
7+
#Change DESCRIPTION to modify what is displayed within a compatible shell (Not compiled in if icon is not present)
8+
#Change COMPRESSED to change if the output program should be a self extracting archive (usually reduces program size)
9+
10+
#----------------------------
11+
TARGET ?= DEMO
12+
DEBUGMODE ?= NDEBUG
13+
ARCHIVED ?= NO
14+
COMPRESSED ?= NO
15+
#----------------------------
16+
ICONPNG ?= iconc.png
17+
DESCRIPTION ?= "C Demo"
18+
#----------------------------
19+
20+
#Add shared library names to the L varible, for instance:
21+
# L := graphx fileioc keypadc
22+
L := graphx
23+
24+
#These directories specify where source and output should go
25+
26+
#----------------------------
27+
SRCDIR := src
28+
OBJDIR := obj
29+
BINDIR := bin
30+
GFXDIR := src/gfx
31+
#----------------------------
32+
33+
#This changes the location of compiled output (Advanced)
34+
35+
#----------------------------
36+
BSSHEAP_LOW := D031F6
37+
BSSHEAP_HIGH := D13FD6
38+
STACK_HIGH := D1A87E
39+
INIT_LOC := D1A87F
40+
#----------------------------
41+
42+
#Use the (slower) OS embedded functions (Advanced)
43+
44+
#----------------------------
45+
USE_FLASH_FUNCTIONS ?= YES
46+
#----------------------------
47+
48+
include $(CEDEV)/include/.makefile

examples/gfx_floodfill/readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### GraphX Flood Fill Demo
2+
3+
This example demonstrates using the flood fill algorithim implemented in GraphX
4+
5+
---
6+
7+
This demo is a part of the C SDK Toolchain for use on the CE.
8+

examples/gfx_floodfill/src/main.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* Keep these headers */
2+
#include <stdbool.h>
3+
#include <stddef.h>
4+
#include <stdint.h>
5+
#include <tice.h>
6+
7+
/* Standard headers - it's recommended to leave them included */
8+
#include <math.h>
9+
#include <stdio.h>
10+
#include <stdlib.h>
11+
#include <string.h>
12+
13+
/* Shared libraries */
14+
#include <libs/graphx.h>
15+
16+
/* Put function prototypes here */
17+
18+
/* Put all your code here */
19+
void main(void) {
20+
int pts[10], i;
21+
22+
int rx = 100;
23+
int ry = 100;
24+
int cx = LCD_WIDTH / 2;
25+
int cy = LCD_HEIGHT / 2;
26+
27+
/* Build the corridinates of the polygon */
28+
double theta = -M_PI / 2;
29+
double dtheta = 4 * M_PI / 5;
30+
for (i = 0; i < 5*2; i+=2) {
31+
pts[i] = (int)(cx + rx * cos(theta)),
32+
pts[i+1] = (int)(cy + ry * sin(theta));
33+
theta += dtheta;
34+
}
35+
36+
/* Initialize the 8bpp graphics */
37+
gfx_Begin( gfx_8bpp );
38+
39+
/* Set up the palette */
40+
gfx_SetColor( gfx_black );
41+
42+
/* Draw a polygon on the buffer */
43+
gfx_Polygon(pts, 5);
44+
45+
/* Pause */
46+
while( !os_GetCSC() );
47+
48+
/* Flood fill the rest of the screen */
49+
gfx_FloodFill(0, 0, 0);
50+
51+
/* Pause */
52+
while( !os_GetCSC() );
53+
54+
/* Close the graphics and return to the OS */
55+
gfx_End();
56+
prgm_CleanUp();
57+
}

src/fileioc/makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# set NAME to the name of the library
66
# set SRC to the assembly source of the library
77
NAME := fileioc
8-
SRC := fileioc.asm
8+
VARN := FILEIOC
99

1010
# defult locations
1111
SPASM ?= spasm
@@ -33,6 +33,7 @@ CP = cp
3333
PREFIX ?= $(HOME)
3434
endif
3535

36+
SRC += $(NAME).asm
3637
DEV ?= $(call NATIVEPATH,$(PREFIX)/CEdev)
3738
BIN ?= $(call NATIVEPATH,$(DEV)/bin)
3839

@@ -46,7 +47,7 @@ EZSRC = $(wildcard *.src)
4647
TBL = relocation_table
4748

4849
LIB_LIB := $(NAME).lib
49-
LIB_8XV := $(NAME).8xv
50+
LIB_8XV := $(VARN).8xv
5051
LIB_ASM := $(NAME)_header.asm
5152
LIB_JMP := $(NAME)_equates.asm
5253
LIB_H := $(NAME).h
@@ -71,7 +72,7 @@ $(LIB_LIB): $(LIB_LIB)($(EZSRC:.src=.obj))
7172
$(RM) $<
7273

7374
clean:
74-
$(RM) $(LIB_8XV) $(LIB_LIB) $(LIB_8XV) $(LIB_ASM) $(LIB_JMP) $(EZOBJ) $(EZSRC) $(TBL)
75+
$(RM) $(LIB_8XV) $(LIB_LIB) $(LIB_ASM) $(LIB_JMP) $(EZOBJ) $(EZSRC) $(TBL)
7576

7677
install:
7778
$(CP) $(LIB_H) $(H_LOC)

0 commit comments

Comments
 (0)