From ab66b5063718a88bd6681fc96d80f57038be0f42 Mon Sep 17 00:00:00 2001 From: Arne van Iterson Date: Sun, 11 Oct 2020 23:43:16 +0200 Subject: [PATCH] Added the bounce --- bin/SOLITAIR.8xp | Bin 2611 -> 8240 bytes bin/SOLITAIR.bin | Bin 2535 -> 8164 bytes bin/SOLITAIR.map | 97 ++++--- obj/gfx/logo_gfx.src | 3 +- obj/main.src | 653 ++++++++++++++++++++++++++++--------------- src/gfx/logo_gfx.c | 3 +- src/gfx/logo_gfx.h | 4 +- src/main.c | 121 ++++---- 8 files changed, 552 insertions(+), 329 deletions(-) diff --git a/bin/SOLITAIR.8xp b/bin/SOLITAIR.8xp index af022e62e8aef23d3011e1d445f9fe7873765798..98b0a8a112db819494a0ca0d6730f56eb7f7a379 100644 GIT binary patch literal 8240 zcmeH~U2IfE6vyY@-R<^kTaXW1P|CJ3wEF;deSr;<@58KVzlv}8)nJ_2Gp_~I>8}3Xt|QMJLQT`Vx;yvpeiGHpK(#X-_|(Fu9zJW~ z6NJw=LesIwp4#8JBZ^c);oTtqs~6qE17ljy=lLOb^7f#S(~s^P)08km!Qa}`$s9fh zwT`Rt?k&^!^UKtF;u_n_{0%oGGGkVO?9`u$^ONS$y#G5aN?{nRBLRgJ!afrY3!?M ze6=T)&EzuB1C-fvRkO`4bJwn(U+>T9z54d-H`hl}iOb2UnfJ!Dtad4P9=zQ*uBGt! zn6@0D5g0V4uo~Aw&EYg&rXnxMq5in`Qe1mGu8qgF3vn&uuS#b86-lM@&knR0E;doct-U}19S5Xj3Vg=MPbD1oy=*24@DDX%#sRasDU~}+*0$t1M zEj~T=5V$*Fn3%#ND$=8{k>R;^hOTl@PqiKeRC)Kz89n-EdwScWVZ)^SjB07IHSU0h z0=iq{S}uX#QV@PwMZr7y{JOpP7+45>xUK`gLei<>bl3;F;L@WN;qhP_b@4%fnbm(G7z?%fO-tx z0Two22KJVi``DArQX)d$5=fq@pU({C>7GXMpo)I!g5NpNriP7r4CG0t@URN~dlgx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EeAzb9% z2r-*~ik`_Dl?Z1I0uvJQH<^g3Nn}D1aU~Q&LOehvTtotVgoDU{pJ0drln`o^j=YYQ z#z3$FK^vpha5`5$3kNFSQk4naJ;t)YgIT@~wpLh-hHx6BA@0vxs#t{141Z@KRC{Lm z|0>@x(mXBl^Q6USkY4;gX=%79g8%Ix%~DO!s7P?2d?hR*hh>|k^Al9Dqz=ikP)22j z0DMkQ!UJSPvSmPVyBbSCs1jZp*-{yi{r^WmWnQVGOy-mZ)bvVs0{@CbPRbILWVr`o l!G+25#o9|3=TTflN3aGi&>&A^5d=@5T`kko5clVe^%sn1ZuI~F delta 506 zcmYL^ze`(D6vxlKNqneiVs&^zmm3EyMQR!erGo}1XGdqpI4KlbNJ{^LMxm=~-g}Fv z;A(_BI2`Z}x?M16aJn=Ro;)91?YXHuGv`&6axV9Sh|#5JOseyP?cz6JN?@) z*vkUen^)DW6+fc=C01+T&p=H9d^a1t*$cc6l=eoY_C_Q-iIhYZsCK)}C{vEi%$r1P9Vx~E%pscA04>=ViP`26xnpvWoA5fHB7}7p6~{lWgtY&^M8 z&q^nfI1!Qo^K?ZiHJPHQGB`DB=yOP~L#5|a{KR0`)|1nPai=VEy^{KigYwyxMeTNZ zT}j~oaDrMklm*&#_m u&&L%4{aa4Do=C4g_n!9B*Y7^Rh4{I8z85O&x76`yZkrvSPk+sE#{K}jy8R3Q diff --git a/bin/SOLITAIR.map b/bin/SOLITAIR.map index 52e72ad..bb62319 100644 --- a/bin/SOLITAIR.map +++ b/bin/SOLITAIR.map @@ -2,45 +2,78 @@ Segment Base Top High Length -------- ------ ------ ------ ------- icon D1A882 D1A882 0h launcher D1A882 D1A8DA 58h -libs D1A8DA D1A913 39h -startup D1A913 D1A952 3Fh -cleanup D1A952 D1A966 14h -exit D1A966 D1A96C 6h -code D1A96C D1AB82 216h -data D1AB82 D1B264 6E2h -strsect D1B264 D1B264 0h -text D1B264 D1B266 2h -bss D031F6 D031F6 D13FD6 0h +libs D1A8DA D1A917 3Dh +startup D1A917 D1A956 3Fh +cleanup D1A956 D1A96A 14h +exit D1A96A D1A970 6h +code D1A970 D1AD8D 41Dh +data D1AD8D D1C863 1AD6h +strsect D1C863 D1C863 0h +text D1C863 D1C863 0h +bss D031F6 D03228 D13FD6 32h header D1A87F D1A882 3h Label Value ------------------------- ------ -_os_DisableHomeTextBuffer = D1A96C -_os_EnableHomeTextBuffer = D1A97E -_random = D1A990 -__state = D1AB82 -__frameset0 = D1A9E7 -__frameset = D1A9F2 -__irems = 00016C -__icmpzero = 000138 -__setflag = 000218 -_rand = D1AA00 +_os_DisableHomeTextBuffer = D1A970 +_os_EnableHomeTextBuffer = D1A982 +_srandom = D1A994 +__setstate = D1A99B +_random = D1A9AB +__state = D1AD8D +__frameset0 = D1AA02 +__seqcase = 000210 +__ltof = 000284 +__frameset = D1AA0D +__fmul = 000288 +__fsub = 000290 +__fneg = D1AA1B +__itol = 000194 +__fcmp = 000274 +__idvrmu = 000140 +__idvrmu = 000144 +__iremu = 000170 +_srand = D1AA28 +_abs = D1AA30 +__fadd = 000270 +__fdiv = 000278 +_rand = D1AA3C +__ftol = 00027C +__ultof = 000280 __findlibload = D1A882 -__ccleanup = D1A952 +__ccleanup = D1A956 _errno = D008DC _init = D1A882 -_exit = D1A968 -__exit = D1A941 -__exitsp = D1A941 -__errsp = D1A941 -_hearts_data = D1ABB4 -_logo_gfx_pal = D1B25A -_main = D1AA34 -_draw_sprite = D1AA0D +_exit = D1A96C +__exit = D1A945 +__exitsp = D1A945 +__errsp = D1A945 +_clubs_data = D1ADBF +_diamonds_data = D1B465 +_hearts_data = D1BB0B +_logo_gfx_pal = D1C1B1 +_spades_data = D1C1BD +_main = D1ABDE +_new_card = D1AACE +_draw_sprite = D1AA49 +_w = D03225 +_card = D03222 +_fr = D0321E +_fd = D0321A +_fv = D03216 +_a = D03212 +_u = D0320E +_v = D0320A +_m = D03206 +_delta = D03202 +_c = D031FE +_dt = D031FA +_t = D031F6 _gfx_Begin = D1A8ED _gfx_End = D1A8F1 _gfx_SetPalette = D1A8F5 -_gfx_SetDraw = D1A8F9 -_gfx_Blit = D1A8FD -_gfx_Sprite = D1A901 -_kb_Scan = D1A90F +_gfx_FillScreen = D1A8F9 +_gfx_SetDraw = D1A8FD +_gfx_Blit = D1A901 +_gfx_Sprite = D1A905 +_kb_Scan = D1A913 diff --git a/obj/gfx/logo_gfx.src b/obj/gfx/logo_gfx.src index a19664a..5551590 100644 --- a/obj/gfx/logo_gfx.src +++ b/obj/gfx/logo_gfx.src @@ -10,10 +10,11 @@ _logo_gfx_pal: DW 31744 DW 60879 DW 0 + DW 33291 XDEF _logo_gfx_pal ; 1 // convpng v7.2 ; 2 #include ; 3 #include "logo_gfx.h" ; 4 -; 5 uint16_t logo_gfx_pal[5] = { +; 5 uint16_t logo_gfx_pal[6] = { END diff --git a/obj/main.src b/obj/main.src index 65ae096..aa672ab 100644 --- a/obj/main.src +++ b/obj/main.src @@ -3,7 +3,33 @@ ; -localcse -const=ROM FILE "SRC\MAIN.C" .assume ADL=1 - SEGMENT CODE + 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 @@ -20,19 +46,50 @@ ; 14 /* Include the sprite data */ ; 15 #include "gfx/logo_gfx.h" ; 16 -; 17 /* Function for drawing the main sprite */ -; 18 void draw_sprite(int x, int y) -; 19 { +; 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 -; 20 /* Fill the screen with color index 0 -; 21 /* Note that this is a super inefficient way to -; 22 /* redraw, but it demonstrates a simple way of clearing past data */ -; 23 // gfx_FillScreen(0xFF); -; 24 -; 25 /* Draw a bunch of different styled sprites on the screen */ -; 26 -; 27 gfx_Sprite(hearts, x, y); +; 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) @@ -43,14 +100,46 @@ _draw_sprite: POP BC POP BC POP BC -; 28 -; 29 /* Copy the buffer to the screen */ -; 30 gfx_BlitBuffer(); // This is the same as gfx_Blit(gfx_buffer) +; 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 -; 31 } +; 39 } LD SP,IX POP IX RET @@ -59,8 +148,12 @@ _draw_sprite: ;**************************** _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 @@ -69,32 +162,147 @@ _draw_sprite: ; Spill Code: 0 (instruction) -; 32 -; 33 void main(void) -; 34 { +; 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,-11 + LD HL,-4 CALL __frameset -; 35 /* Coordinates used for the sprite */ -; 36 int x, y; -; 37 bool gravity[2] = { -; 38 true, -; 39 true}; - LEA DE,IX+-8 - LD HL,_0temp1 - LD BC,2 - LDIR -; 40 float angle; -; 41 -; 42 /* Initialize the 8bpp graphics */ -; 43 gfx_Begin(); +; 60 srand(rtc_Time()); + LD BC,(15925316) + PUSH BC + CALL _srand + POP BC +; 61 +; 62 gfx_Begin(); CALL _gfx_Begin -; 44 -; 45 /* Set up the palette for our sprites */ -; 46 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0); +; 63 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0); LD BC,0 PUSH BC - LD BC,10 + LD BC,12 PUSH BC LD BC,_logo_gfx_pal PUSH BC @@ -102,191 +310,157 @@ _main: POP BC POP BC POP BC -; 47 -; 48 /* Start at 0, 0 */ -; 49 x = 0; - LD BC,0 - LD (IX+-6),BC -; 50 y = (rand() % (LCD_HEIGHT - 0 + 1)); - CALL _rand - LD BC,241 - CALL __irems - LD (IX+-3),HL -; 51 -; 52 gfx_SetDrawBuffer(); +; 64 gfx_SetDrawBuffer(); LD BC,1 PUSH BC CALL _gfx_SetDraw POP BC -; 53 -; 54 //gfx_FillScreen(1); -; 55 -; 56 draw_sprite(x, y); - LD BC,(IX+-3) +; 65 gfx_FillScreen(0x05); + LD BC,5 PUSH BC - LD BC,0 - PUSH BC - CALL _draw_sprite + CALL _gfx_FillScreen POP BC - POP BC -; 57 -; 58 do -L_18: -; 59 { -; 60 /* Scan the keypad to update kb_Data */ -; 61 kb_Scan(); +; 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 -; 62 -; 63 if ((x + hearts_width) <= LCD_WIDTH && x >= 0) - LD IY,(IX+-6) - LEA BC,IY+34 - LD HL,320 - OR A,A - SBC HL,BC - CALL __setflag - JP M,L_8 - LD HL,(IX+-6) - CALL __icmpzero - CALL __setflag - JP M,L_8 -; 64 { -; 65 if (gravity[0]) - LD A,(IX+-8) - OR A,A - JR Z,L_4 -; 66 { -; 67 x = x + 2; - LD IY,(IX+-6) - LEA IY,IY+2 - LD (IX+-6),IY -; 68 } -; 69 else - JR L_16 -L_4: -; 70 { -; 71 x = x - 2; - LD IY,(IX+-6) - LEA IY,IY+-2 - LD (IX+-6),IY -; 72 } -; 73 } -; 74 else - JR L_16 -L_8: -; 75 { -; 76 if (gravity[0]) - LD A,(IX+-8) - OR A,A - JR Z,L_6 -; 77 { -; 78 gravity[0] = false; - LD (IX+-8),0 -; 79 x = x - 2; - LD IY,(IX+-6) - LEA IY,IY+-2 - LD (IX+-6),IY -; 80 } -; 81 else - JR L_16 -L_6: -; 82 { -; 83 gravity[0] = true; - LD (IX+-8),1 -; 84 x = x + 2; - LD IY,(IX+-6) - LEA IY,IY+2 - LD (IX+-6),IY -; 85 } -; 86 } -L_16: -; 87 -; 88 if ((y + hearts_height) <= LCD_HEIGHT && y >= 0) - LD IY,(IX+-3) - LEA BC,IY+50 - LD HL,240 - OR A,A - SBC HL,BC - JP M,L_15 - LD HL,(IX+-3) - CALL __icmpzero - CALL __setflag - JP M,L_15 -; 89 { -; 90 if (gravity[1]) - LEA HL,IX+-8 - INC HL - LD A,(HL) - OR A,A - JR Z,L_11 -; 91 { -; 92 y = y + 2; - LD IY,(IX+-3) - LEA IY,IY+2 - LD (IX+-3),IY -; 93 } -; 94 else - JR L_17 -L_11: -; 95 { -; 96 y = y - 2; - LD IY,(IX+-3) - LEA IY,IY+-2 - LD (IX+-3),IY -; 97 } -; 98 } -; 99 else - JR L_17 -L_15: -; 100 { -; 101 if (gravity[1]) - LEA BC,IX+-8 - INC BC - LD (IX+-11),BC +; 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 A,(HL) - OR A,A - JR Z,L_13 -; 102 { -; 103 gravity[1] = false; - LD HL,(IX+-11) - LD (HL),0 -; 104 y = y - 2; - LD IY,(IX+-3) - LEA IY,IY+-2 - LD (IX+-3),IY -; 105 } -; 106 else - JR L_17 -L_13: -; 107 { -; 108 gravity[1] = true; - LD HL,(IX+-11) - LD (HL),1 -; 109 y = y + 2; - LD IY,(IX+-3) - LEA IY,IY+2 - LD (IX+-3),IY -; 110 } -; 111 } -L_17: -; 112 -; 113 draw_sprite(x, y); - LD BC,(IX+-3) + 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 - LD BC,(IX+-6) + 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 -; 114 } while (kb_Data[6] != kb_Clear); +; 89 } +; 90 +; 91 } while (kb_Data[6] != kb_Clear); +L_10: LD A,(16056348) CP A,64 - JR NZ,L_18 -; 115 -; 116 /* Close the graphics */ -; 117 gfx_End(); + JR NZ,L_9 +; 92 +; 93 /* Close the graphics */ +; 94 gfx_End(); CALL _gfx_End -; 118 } +; 95 } LD SP,IX POP IX RET @@ -295,42 +469,79 @@ L_17: ;**************************** _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 -;_rand IMPORT ----- function -;_logo_gfx_pal IMPORT 10 variable +;_logo_gfx_pal IMPORT 12 variable ;_gfx_SetPalette IMPORT ----- function ;_gfx_Begin IMPORT ----- function -;_0temp1 STATIC 2 variable -;G_0 IX-11 3 variable -;gravity IX-8 2 variable -;x IX-6 3 variable -;y IX-3 3 variable +;_srand IMPORT ----- function +;G_0 IX-4 4 variable -; Stack Frame Size: 17 (bytes) +; Stack Frame Size: 10 (bytes) ; Spill Code: 0 (instruction) - SEGMENT TEXT -_0temp1: - DB 1 - DB 1 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 __irems: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 __setflag:ROM - XREF __icmpzero: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 diff --git a/src/gfx/logo_gfx.c b/src/gfx/logo_gfx.c index 0e2fa76..3202037 100644 --- a/src/gfx/logo_gfx.c +++ b/src/gfx/logo_gfx.c @@ -2,10 +2,11 @@ #include #include "logo_gfx.h" -uint16_t logo_gfx_pal[5] = { +uint16_t logo_gfx_pal[6] = { 0xFFFF, // 00 :: rgb(255,255,255) 0x0000, // 01 :: rgb(0,0,0) 0x7C00, // 02 :: rgb(255,0,0) 0xEDCF, // 03 :: rgb(221,116,125) 0x0000, // 04 :: rgb(0,0,0) + 0x820B, }; diff --git a/src/gfx/logo_gfx.h b/src/gfx/logo_gfx.h index 39cdf22..37a9657 100644 --- a/src/gfx/logo_gfx.h +++ b/src/gfx/logo_gfx.h @@ -26,7 +26,7 @@ extern uint8_t spades_data[1702]; #define clubs_size 1702 extern uint8_t clubs_data[1702]; #define clubs ((gfx_sprite_t*)clubs_data) -#define sizeof_logo_gfx_pal 10 -extern uint16_t logo_gfx_pal[5]; +#define sizeof_logo_gfx_pal 12 +extern uint16_t logo_gfx_pal[6]; #endif diff --git a/src/main.c b/src/main.c index 69e9464..b94e4e3 100644 --- a/src/main.c +++ b/src/main.c @@ -14,103 +14,80 @@ /* Include the sprite data */ #include "gfx/logo_gfx.h" -/* Function for drawing the main sprite */ +float t, dt, c, delta, m, v, u, a, fv, fd, fr; +int card, w; + void draw_sprite(int x, int y) { - /* Fill the screen with color index 0 - /* Note that this is a super inefficient way to - /* redraw, but it demonstrates a simple way of clearing past data */ - // gfx_FillScreen(0xFF); + switch (card) + { + case 0: + gfx_Sprite(diamonds, x, y); + break; + case 1: + gfx_Sprite(hearts, x, y); + break; + case 2: + gfx_Sprite(spades, x, y); + break; + case 3: + gfx_Sprite(clubs, x, y); + break; + } - /* Draw a bunch of different styled sprites on the screen */ + gfx_BlitBuffer(); +} - gfx_Sprite(hearts, x, y); - - /* Copy the buffer to the screen */ - gfx_BlitBuffer(); // This is the same as gfx_Blit(gfx_buffer) +void new_card() +{ + card = randInt(0, 3); + t = randInt(5, LCD_WIDTH / 6) / w; + w = randInt(10, 30); + dt = 0.075; + c = randInt(2, 8); + delta = (float)rand() / (float)RAND_MAX * 5; + m = 20; + v = randInt(0, 100); + u = (LCD_HEIGHT - hearts_height) - 5; + a = 0; + fv = 0; + fd = 0; + fr = 0; } void main(void) { - /* Coordinates used for the sprite */ - int x, y; - bool gravity[2] = { - true, - true}; - float angle; + srand(rtc_Time()); - /* Initialize the 8bpp graphics */ gfx_Begin(); - - /* Set up the palette for our sprites */ gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0); - - /* Start at 0, 0 */ - x = 0; - y = (rand() % (LCD_HEIGHT - 0 + 1)); - gfx_SetDrawBuffer(); + gfx_FillScreen(0x05); - //gfx_FillScreen(1); - - draw_sprite(x, y); + new_card(); do { /* Scan the keypad to update kb_Data */ kb_Scan(); - if ((x + hearts_width) <= LCD_WIDTH && x >= 0) + fv = c * u; + fd = delta * v; + fr = -fv - fd; + a = fr / m; + v = v + a * dt; + u = u + v * dt; + t = t + dt; + + if (t * w > LCD_WIDTH) { - if (gravity[0]) - { - x = x + 2; - } - else - { - x = x - 2; - } + new_card(); } else { - if (gravity[0]) - { - gravity[0] = false; - x = x - 2; - } - else - { - gravity[0] = true; - x = x + 2; - } + draw_sprite(t * w, (LCD_HEIGHT - hearts_height) - abs(u)); } - if ((y + hearts_height) <= LCD_HEIGHT && y >= 0) - { - if (gravity[1]) - { - y = y + 2; - } - else - { - y = y - 2; - } - } - else - { - if (gravity[1]) - { - gravity[1] = false; - y = y - 2; - } - else - { - gravity[1] = true; - y = y + 2; - } - } - - draw_sprite(x, y); } while (kb_Data[6] != kb_Clear); /* Close the graphics */