; Zilog eZ80 ANSI C Compiler Release 3.4 ; -optsize -noreduceopt -nomodsect -peephole -globalopt ; -localcse -const=ROM FILE "SRC\MAIN.C" .assume ADL=1 SEGMENT BSS _t: DS 4*1 _dt: DS 4*1 _c: DS 4*1 _delta: DS 4*1 _m: DS 4*1 _v: DS 4*1 _u: DS 4*1 _a: DS 4*1 _fv: DS 4*1 _fd: DS 4*1 _fr: DS 4*1 _card: DS 3 _w: DS 3 ; 1 #include ; 2 #include ; 3 #include ; 4 #include ; 5 ; 6 #include ; 7 #include ; 8 #include ; 9 #include ; 10 ; 11 #include ; 12 #include ; 13 ; 14 /* Include the sprite data */ ; 15 #include "gfx/logo_gfx.h" ; 16 ; 17 float t, dt, c, delta, m, v, u, a, fv, fd, fr; ; 18 int card, w; SEGMENT CODE ; 19 ; 20 void draw_sprite(int x, int y) ; 21 { _draw_sprite: CALL __frameset0 ; 22 switch (card) LD HL,(_card) CALL __seqcase L__0: DW 4 DW 0 DB 0 DW24 L_0 DW24 L_1 DW24 L_2 DW24 L_3 DW24 L_4 ; 23 { ; 24 case 0: L_0: ; 25 gfx_Sprite(diamonds, x, y); LD BC,(IX+9) PUSH BC LD BC,(IX+6) PUSH BC LD BC,_diamonds_data PUSH BC CALL _gfx_Sprite POP BC POP BC POP BC ; 26 break; JR L_4 ; 27 case 1: L_1: ; 28 gfx_Sprite(hearts, x, y); LD BC,(IX+9) PUSH BC LD BC,(IX+6) PUSH BC LD BC,_hearts_data PUSH BC CALL _gfx_Sprite POP BC POP BC POP BC ; 29 break; JR L_4 ; 30 case 2: L_2: ; 31 gfx_Sprite(spades, x, y); LD BC,(IX+9) PUSH BC LD BC,(IX+6) PUSH BC LD BC,_spades_data PUSH BC CALL _gfx_Sprite POP BC POP BC POP BC ; 32 break; JR L_4 ; 33 case 3: L_3: ; 34 gfx_Sprite(clubs, x, y); LD BC,(IX+9) PUSH BC LD BC,(IX+6) PUSH BC LD BC,_clubs_data PUSH BC CALL _gfx_Sprite POP BC POP BC POP BC ; 35 break; ; 36 } L_4: ; 37 ; 38 gfx_BlitBuffer(); LD BC,1 PUSH BC CALL _gfx_Blit POP BC ; 39 } LD SP,IX POP IX RET ;**************************** _draw_sprite *************************** ;Name Addr/Register Size Type ;_gfx_Blit IMPORT ----- function ;_clubs_data IMPORT 1702 variable ;_spades_data IMPORT 1702 variable ;_hearts_data IMPORT 1702 variable ;_diamonds_data IMPORT 1702 variable ;_gfx_Sprite IMPORT ----- function ;_card STATIC 3 variable ;y IX+9 3 parameter ;x IX+6 3 parameter ; Stack Frame Size: 12 (bytes) ; Spill Code: 0 (instruction) ; 40 ; 41 void new_card() ; 42 { _new_card: ; 43 card = randInt(0, 3); CALL _random LD A,L AND A,3 UEXT HL LD L,A LD (_card),HL ; 44 t = randInt(5, LCD_WIDTH / 6) / w; CALL _random LD BC,49 CALL __iremu LD IY,HL LEA HL,IY+5 LD BC,(_w) CALL __idivu LD BC,HL XOR A,A CALL __ultof LD (_t),BC LD (_t+3),A ; 45 w = randInt(10, 30); CALL _random LD BC,21 CALL __iremu LD IY,HL LEA BC,IY+10 LD (_w),BC ; 46 dt = 0.075; LD BC,10066330 LD (_dt),BC LD A,61 LD (_dt+3),A ; 47 c = randInt(2, 8); CALL _random LD BC,7 CALL __iremu INC HL INC HL LD BC,HL XOR A,A CALL __ultof LD (_c),BC LD (_c+3),A ; 48 delta = (float)rand() / (float)RAND_MAX * 5; CALL _rand LD BC,HL CALL __itol CALL __ltof LD HL,16777214 LD E,74 CALL __fdiv LD HL,10485760 LD E,64 CALL __fmul LD (_delta),BC LD (_delta+3),A ; 49 m = 20; LD BC,10485760 LD (_m),BC LD A,65 LD (_m+3),A ; 50 v = randInt(0, 100); CALL _random LD BC,101 CALL __iremu LD BC,HL XOR A,A CALL __ultof LD (_v),BC LD (_v+3),A ; 51 u = (LCD_HEIGHT - hearts_height) - 5; LD BC,3735552 LD (_u),BC LD A,67 LD (_u+3),A ; 52 a = 0; LD BC,0 LD (_a),BC XOR A,A LD (_a+3),A ; 53 fv = 0; LD (_fv),BC XOR A,A LD (_fv+3),A ; 54 fd = 0; LD (_fd),BC XOR A,A LD (_fd+3),A ; 55 fr = 0; LD (_fr),BC XOR A,A LD (_fr+3),A ; 56 } RET ;**************************** _new_card *************************** ;Name Addr/Register Size Type ;_fr STATIC 4 variable ;_fd STATIC 4 variable ;_fv STATIC 4 variable ;_a STATIC 4 variable ;_u STATIC 4 variable ;_v STATIC 4 variable ;_m STATIC 4 variable ;_delta STATIC 4 variable ;_rand IMPORT ----- function ;_c STATIC 4 variable ;_dt STATIC 4 variable ;_t STATIC 4 variable ;_w STATIC 3 variable ;_card STATIC 3 variable ;_random IMPORT ----- function ; Stack Frame Size: 6 (bytes) ; Spill Code: 0 (instruction) ; 57 ; 58 void main(void) ; 59 { _main: LD HL,-4 CALL __frameset ; 60 srand(rtc_Time()); LD BC,(15925316) PUSH BC CALL _srand POP BC ; 61 ; 62 gfx_Begin(); CALL _gfx_Begin ; 63 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0); LD BC,0 PUSH BC LD BC,12 PUSH BC LD BC,_logo_gfx_pal PUSH BC CALL _gfx_SetPalette POP BC POP BC POP BC ; 64 gfx_SetDrawBuffer(); LD BC,1 PUSH BC CALL _gfx_SetDraw POP BC ; 65 gfx_FillScreen(0x05); LD BC,5 PUSH BC CALL _gfx_FillScreen POP BC ; 66 ; 67 new_card(); CALL _new_card ; 68 ; 69 do L_9: ; 70 { ; 71 /* Scan the keypad to update kb_Data */ ; 72 kb_Scan(); CALL _kb_Scan ; 73 ; 74 fv = c * u; LD A,(_u+3) LD E,A LD A,(_c+3) LD HL,(_u) LD BC,(_c) CALL __fmul LD (_fv),BC LD (_fv+3),A ; 75 fd = delta * v; LD A,(_v+3) LD E,A LD A,(_delta+3) LD HL,(_v) LD BC,(_delta) CALL __fmul LD (_fd),BC LD (_fd+3),A ; 76 fr = -fv - fd; LD BC,(_fv) LD A,(_fv+3) CALL __fneg LD H,A LD A,(_fd+3) LD E,A LD A,H LD HL,(_fd) CALL __fsub LD (_fr),BC LD (_fr+3),A ; 77 a = fr / m; LD A,(_m+3) LD E,A LD A,(_fr+3) LD HL,(_m) CALL __fdiv LD (_a),BC LD (_a+3),A ; 78 v = v + a * dt; LD A,(_dt+3) LD E,A LD A,(_a+3) LD HL,(_dt) CALL __fmul LD H,A LD A,(_v+3) LD E,A LD A,H LD HL,(_v) CALL __fadd LD (_v),BC LD (_v+3),A ; 79 u = u + v * dt; LD A,(_dt+3) LD E,A LD A,(_v+3) LD HL,(_dt) CALL __fmul LD H,A LD A,(_u+3) LD E,A LD A,H LD HL,(_u) CALL __fadd LD (_u),BC LD (_u+3),A ; 80 t = t + dt; LD A,(_dt+3) LD E,A LD A,(_t+3) LD HL,(_dt) LD BC,(_t) CALL __fadd LD (_t),BC LD (_t+3),A ; 81 ; 82 if (t * w > LCD_WIDTH) LD BC,(_w) CALL __itol CALL __ltof LD E,A LD HL,BC LD BC,(_t) LD A,(_t+3) CALL __fmul LD (IX+-4),BC LD (IX+-1),A LD HL,10485760 LD E,67 CALL __fcmp JP P,L_8 ; 83 { ; 84 new_card(); CALL _new_card ; 85 } ; 86 else JR L_10 L_8: ; 87 { ; 88 draw_sprite(t * w, (LCD_HEIGHT - hearts_height) - abs(u)); LD BC,(_u) LD A,(_u+3) CALL __ftol PUSH BC CALL _abs POP BC LD BC,HL LD HL,190 OR A,A SBC HL,BC PUSH HL LD BC,(IX+-4) LD A,(IX+-1) CALL __ftol PUSH BC CALL _draw_sprite POP BC POP BC ; 89 } ; 90 ; 91 } while (kb_Data[6] != kb_Clear); L_10: LD A,(16056348) CP A,64 JR NZ,L_9 ; 92 ; 93 /* Close the graphics */ ; 94 gfx_End(); CALL _gfx_End ; 95 } LD SP,IX POP IX RET ;**************************** _main *************************** ;Name Addr/Register Size Type ;_gfx_End IMPORT ----- function ;_abs IMPORT ----- function ;_w STATIC 3 variable ;_t STATIC 4 variable ;_dt STATIC 4 variable ;_a STATIC 4 variable ;_m STATIC 4 variable ;_fr STATIC 4 variable ;_fd STATIC 4 variable ;_v STATIC 4 variable ;_delta STATIC 4 variable ;_fv STATIC 4 variable ;_u STATIC 4 variable ;_c STATIC 4 variable ;_kb_Scan IMPORT ----- function ;_gfx_FillScreen IMPORT ----- function ;_gfx_SetDraw IMPORT ----- function ;_logo_gfx_pal IMPORT 12 variable ;_gfx_SetPalette IMPORT ----- function ;_gfx_Begin IMPORT ----- function ;_srand IMPORT ----- function ;G_0 IX-4 4 variable ; Stack Frame Size: 10 (bytes) ; Spill Code: 0 (instruction) XREF _logo_gfx_pal:ROM XREF _clubs_data:ROM XREF _spades_data:ROM XREF _hearts_data:ROM XREF _diamonds_data:ROM XREF _kb_Scan:ROM XREF _gfx_Sprite:ROM XREF _gfx_Blit:ROM XREF _gfx_SetDraw:ROM XREF _gfx_FillScreen:ROM XREF _gfx_SetPalette:ROM XREF _gfx_End:ROM XREF _gfx_Begin:ROM XREF _abs:ROM XREF _rand:ROM XREF _srand:ROM XREF _random:ROM XREF __idivu:ROM XREF __iremu:ROM XREF __fadd:ROM XREF __fsub:ROM XREF __fmul:ROM XREF __fdiv:ROM XREF __fneg:ROM XREF __fcmp:ROM XREF __ftol:ROM XREF __ltof:ROM XREF __ultof:ROM XREF __itol:ROM XREF __frameset0:ROM XREF __frameset:ROM XREF __seqcase:ROM XDEF _main XDEF _new_card XDEF _draw_sprite XDEF _w XDEF _card XDEF _fr XDEF _fd XDEF _fv XDEF _a XDEF _u XDEF _v XDEF _m XDEF _delta XDEF _c XDEF _dt XDEF _t END