mirror of
https://github.com/Pixinn/gameoflife-appleii.git
synced 2024-05-28 06:41:29 +00:00
Using the random colors!
This commit is contained in:
parent
3d08413c9c
commit
1f97d75428
17
gol_apple2.c
17
gol_apple2.c
|
@ -54,9 +54,9 @@ char KeyPressed = NO_KEY;
|
|||
|
||||
/******************* STATIC GLOBAL VARIABLES ******************/
|
||||
|
||||
uint8_t Cells[ NB_COLUMNS ][ NB_LINES ];
|
||||
uint8_t Cells_Future[ NB_COLUMNS ][ NB_LINES ];
|
||||
uint8_t Cells_Initial[ NB_COLUMNS ][ NB_LINES ];
|
||||
static uint8_t Cells[ NB_COLUMNS ][ NB_LINES ];
|
||||
static uint8_t Cells_Future[ NB_COLUMNS ][ NB_LINES ];
|
||||
static uint8_t Cells_Initial[ NB_COLUMNS ][ NB_LINES ];
|
||||
|
||||
/******************** CODE ************************/
|
||||
|
||||
|
@ -66,9 +66,6 @@ int main( int argc, char** argv )
|
|||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
printf("PAUSE");
|
||||
cgetc();
|
||||
|
||||
init_asm( (uint8_t*)Cells, (uint8_t*)Cells_Future );
|
||||
init_rnd_color();
|
||||
|
||||
|
@ -114,8 +111,8 @@ void quit( void )
|
|||
uint8_t x, y;
|
||||
mode_text();
|
||||
screensize (&x, &y);
|
||||
gotoxy( 1u, y-1u );
|
||||
printf("BYE BYE!");
|
||||
clrscr();
|
||||
printf("\n*** THIS WAS LIFE BY WWW.XTOF.INFO ***\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -224,7 +221,7 @@ void toggle_cell( const uint8_t x, const uint8_t y )
|
|||
cell = &Cells[x][y];
|
||||
if( *cell == DEAD ) {
|
||||
*cell = ALIVE;
|
||||
gfx_pixel( CELL_COLOR, x, y );
|
||||
gfx_pixel( get_color(), x, y );
|
||||
} else {
|
||||
*cell = DEAD;
|
||||
gfx_pixel( BLACK, x, y );
|
||||
|
@ -276,7 +273,7 @@ void __fastcall__ update( void )
|
|||
}
|
||||
else if( *cell_curr == DEAD && nb_neighbours == 3u ) {
|
||||
*cell_future_line = ALIVE;
|
||||
gfx_pixel( CELL_COLOR, x, y );
|
||||
gfx_pixel( get_color(), x, y );
|
||||
}
|
||||
cell_curr += NB_LINES;
|
||||
cell_neighbourhoud_line += NB_LINES;
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
.import popa
|
||||
|
||||
.export _init_rnd_color
|
||||
.export _get_color
|
||||
|
||||
|
||||
.BSS
|
||||
Colors: .dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
.dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
.dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
.dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
Colors: .dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
.dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
.dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
.dword $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0, $0
|
||||
|
||||
Color: .byte $0
|
||||
|
||||
.CODE
|
||||
|
||||
|
@ -53,3 +55,15 @@ loop_end:
|
|||
JSR popa
|
||||
STA tmp1
|
||||
RTS
|
||||
|
||||
|
||||
|
||||
; uint8_t __fastcall__ get_color( void )
|
||||
; Gets the next color from the buffer
|
||||
_get_color:
|
||||
LDX Color
|
||||
LDA Colors,X
|
||||
INX
|
||||
STX Color
|
||||
LDX #0
|
||||
RTS
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef __RND_COLOTS__H_
|
||||
#define __RND_COLOTS__H_
|
||||
|
||||
void init_rnd_color( void ); /* Inits a buffer of 256 random colors */
|
||||
extern uint8_t Colors[256];
|
||||
|
||||
void __fastcall__ init_rnd_color( void ); /* Inits a buffer of 256 random colors */
|
||||
uint8_t __fastcall__ get_color( void ); /* Gets the next color from the buffer */
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user