Added the bounce

This commit is contained in:
Arne van Iterson 2020-10-11 23:43:16 +02:00
parent 232a2858b0
commit ab66b50637
8 changed files with 552 additions and 329 deletions

Binary file not shown.

Binary file not shown.

View File

@ -2,45 +2,78 @@ Segment Base Top High Length
-------- ------ ------ ------ ------- -------- ------ ------ ------ -------
icon D1A882 D1A882 0h icon D1A882 D1A882 0h
launcher D1A882 D1A8DA 58h launcher D1A882 D1A8DA 58h
libs D1A8DA D1A913 39h libs D1A8DA D1A917 3Dh
startup D1A913 D1A952 3Fh startup D1A917 D1A956 3Fh
cleanup D1A952 D1A966 14h cleanup D1A956 D1A96A 14h
exit D1A966 D1A96C 6h exit D1A96A D1A970 6h
code D1A96C D1AB82 216h code D1A970 D1AD8D 41Dh
data D1AB82 D1B264 6E2h data D1AD8D D1C863 1AD6h
strsect D1B264 D1B264 0h strsect D1C863 D1C863 0h
text D1B264 D1B266 2h text D1C863 D1C863 0h
bss D031F6 D031F6 D13FD6 0h bss D031F6 D03228 D13FD6 32h
header D1A87F D1A882 3h header D1A87F D1A882 3h
Label Value Label Value
------------------------- ------ ------------------------- ------
_os_DisableHomeTextBuffer = D1A96C _os_DisableHomeTextBuffer = D1A970
_os_EnableHomeTextBuffer = D1A97E _os_EnableHomeTextBuffer = D1A982
_random = D1A990 _srandom = D1A994
__state = D1AB82 __setstate = D1A99B
__frameset0 = D1A9E7 _random = D1A9AB
__frameset = D1A9F2 __state = D1AD8D
__irems = 00016C __frameset0 = D1AA02
__icmpzero = 000138 __seqcase = 000210
__setflag = 000218 __ltof = 000284
_rand = D1AA00 __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 __findlibload = D1A882
__ccleanup = D1A952 __ccleanup = D1A956
_errno = D008DC _errno = D008DC
_init = D1A882 _init = D1A882
_exit = D1A968 _exit = D1A96C
__exit = D1A941 __exit = D1A945
__exitsp = D1A941 __exitsp = D1A945
__errsp = D1A941 __errsp = D1A945
_hearts_data = D1ABB4 _clubs_data = D1ADBF
_logo_gfx_pal = D1B25A _diamonds_data = D1B465
_main = D1AA34 _hearts_data = D1BB0B
_draw_sprite = D1AA0D _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_Begin = D1A8ED
_gfx_End = D1A8F1 _gfx_End = D1A8F1
_gfx_SetPalette = D1A8F5 _gfx_SetPalette = D1A8F5
_gfx_SetDraw = D1A8F9 _gfx_FillScreen = D1A8F9
_gfx_Blit = D1A8FD _gfx_SetDraw = D1A8FD
_gfx_Sprite = D1A901 _gfx_Blit = D1A901
_kb_Scan = D1A90F _gfx_Sprite = D1A905
_kb_Scan = D1A913

View File

@ -10,10 +10,11 @@ _logo_gfx_pal:
DW 31744 DW 31744
DW 60879 DW 60879
DW 0 DW 0
DW 33291
XDEF _logo_gfx_pal XDEF _logo_gfx_pal
; 1 // convpng v7.2 ; 1 // convpng v7.2
; 2 #include <stdint.h> ; 2 #include <stdint.h>
; 3 #include "logo_gfx.h" ; 3 #include "logo_gfx.h"
; 4 ; 4
; 5 uint16_t logo_gfx_pal[5] = { ; 5 uint16_t logo_gfx_pal[6] = {
END END

View File

@ -3,7 +3,33 @@
; -localcse -const=ROM ; -localcse -const=ROM
FILE "SRC\MAIN.C" FILE "SRC\MAIN.C"
.assume ADL=1 .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 <stdbool.h> ; 1 #include <stdbool.h>
; 2 #include <stddef.h> ; 2 #include <stddef.h>
; 3 #include <stdint.h> ; 3 #include <stdint.h>
@ -20,19 +46,50 @@
; 14 /* Include the sprite data */ ; 14 /* Include the sprite data */
; 15 #include "gfx/logo_gfx.h" ; 15 #include "gfx/logo_gfx.h"
; 16 ; 16
; 17 /* Function for drawing the main sprite */ ; 17 float t, dt, c, delta, m, v, u, a, fv, fd, fr;
; 18 void draw_sprite(int x, int y) ; 18 int card, w;
; 19 { SEGMENT CODE
; 19
; 20 void draw_sprite(int x, int y)
; 21 {
_draw_sprite: _draw_sprite:
CALL __frameset0 CALL __frameset0
; 20 /* Fill the screen with color index 0 ; 22 switch (card)
; 21 /* Note that this is a super inefficient way to LD HL,(_card)
; 22 /* redraw, but it demonstrates a simple way of clearing past data */ CALL __seqcase
; 23 // gfx_FillScreen(0xFF); L__0:
; 24 DW 4
; 25 /* Draw a bunch of different styled sprites on the screen */ DW 0
; 26 DB 0
; 27 gfx_Sprite(hearts, x, y); 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) LD BC,(IX+9)
PUSH BC PUSH BC
LD BC,(IX+6) LD BC,(IX+6)
@ -43,14 +100,46 @@ _draw_sprite:
POP BC POP BC
POP BC POP BC
POP BC POP BC
; 28 ; 29 break;
; 29 /* Copy the buffer to the screen */ JR L_4
; 30 gfx_BlitBuffer(); // This is the same as gfx_Blit(gfx_buffer) ; 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 LD BC,1
PUSH BC PUSH BC
CALL _gfx_Blit CALL _gfx_Blit
POP BC POP BC
; 31 } ; 39 }
LD SP,IX LD SP,IX
POP IX POP IX
RET RET
@ -59,8 +148,12 @@ _draw_sprite:
;**************************** _draw_sprite *************************** ;**************************** _draw_sprite ***************************
;Name Addr/Register Size Type ;Name Addr/Register Size Type
;_gfx_Blit IMPORT ----- function ;_gfx_Blit IMPORT ----- function
;_clubs_data IMPORT 1702 variable
;_spades_data IMPORT 1702 variable
;_hearts_data IMPORT 1702 variable ;_hearts_data IMPORT 1702 variable
;_diamonds_data IMPORT 1702 variable
;_gfx_Sprite IMPORT ----- function ;_gfx_Sprite IMPORT ----- function
;_card STATIC 3 variable
;y IX+9 3 parameter ;y IX+9 3 parameter
;x IX+6 3 parameter ;x IX+6 3 parameter
@ -69,32 +162,147 @@ _draw_sprite:
; Spill Code: 0 (instruction) ; Spill Code: 0 (instruction)
; 32 ; 40
; 33 void main(void) ; 41 void new_card()
; 34 { ; 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: _main:
LD HL,-11 LD HL,-4
CALL __frameset CALL __frameset
; 35 /* Coordinates used for the sprite */ ; 60 srand(rtc_Time());
; 36 int x, y; LD BC,(15925316)
; 37 bool gravity[2] = { PUSH BC
; 38 true, CALL _srand
; 39 true}; POP BC
LEA DE,IX+-8 ; 61
LD HL,_0temp1 ; 62 gfx_Begin();
LD BC,2
LDIR
; 40 float angle;
; 41
; 42 /* Initialize the 8bpp graphics */
; 43 gfx_Begin();
CALL _gfx_Begin CALL _gfx_Begin
; 44 ; 63 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
; 45 /* Set up the palette for our sprites */
; 46 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
LD BC,0 LD BC,0
PUSH BC PUSH BC
LD BC,10 LD BC,12
PUSH BC PUSH BC
LD BC,_logo_gfx_pal LD BC,_logo_gfx_pal
PUSH BC PUSH BC
@ -102,191 +310,157 @@ _main:
POP BC POP BC
POP BC POP BC
POP BC POP BC
; 47 ; 64 gfx_SetDrawBuffer();
; 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();
LD BC,1 LD BC,1
PUSH BC PUSH BC
CALL _gfx_SetDraw CALL _gfx_SetDraw
POP BC POP BC
; 53 ; 65 gfx_FillScreen(0x05);
; 54 //gfx_FillScreen(1); LD BC,5
; 55
; 56 draw_sprite(x, y);
LD BC,(IX+-3)
PUSH BC PUSH BC
LD BC,0 CALL _gfx_FillScreen
PUSH BC
CALL _draw_sprite
POP BC POP BC
POP BC ; 66
; 57 ; 67 new_card();
; 58 do CALL _new_card
L_18: ; 68
; 59 { ; 69 do
; 60 /* Scan the keypad to update kb_Data */ L_9:
; 61 kb_Scan(); ; 70 {
; 71 /* Scan the keypad to update kb_Data */
; 72 kb_Scan();
CALL _kb_Scan CALL _kb_Scan
; 62 ; 73
; 63 if ((x + hearts_width) <= LCD_WIDTH && x >= 0) ; 74 fv = c * u;
LD IY,(IX+-6) LD A,(_u+3)
LEA BC,IY+34 LD E,A
LD HL,320 LD A,(_c+3)
OR A,A LD HL,(_u)
SBC HL,BC LD BC,(_c)
CALL __setflag CALL __fmul
JP M,L_8 LD (_fv),BC
LD HL,(IX+-6) LD (_fv+3),A
CALL __icmpzero ; 75 fd = delta * v;
CALL __setflag LD A,(_v+3)
JP M,L_8 LD E,A
; 64 { LD A,(_delta+3)
; 65 if (gravity[0]) LD HL,(_v)
LD A,(IX+-8) LD BC,(_delta)
OR A,A CALL __fmul
JR Z,L_4 LD (_fd),BC
; 66 { LD (_fd+3),A
; 67 x = x + 2; ; 76 fr = -fv - fd;
LD IY,(IX+-6) LD BC,(_fv)
LEA IY,IY+2 LD A,(_fv+3)
LD (IX+-6),IY CALL __fneg
; 68 } LD H,A
; 69 else LD A,(_fd+3)
JR L_16 LD E,A
L_4: LD A,H
; 70 { LD HL,(_fd)
; 71 x = x - 2; CALL __fsub
LD IY,(IX+-6) LD (_fr),BC
LEA IY,IY+-2 LD (_fr+3),A
LD (IX+-6),IY ; 77 a = fr / m;
; 72 } LD A,(_m+3)
; 73 } LD E,A
; 74 else LD A,(_fr+3)
JR L_16 LD HL,(_m)
L_8: CALL __fdiv
; 75 { LD (_a),BC
; 76 if (gravity[0]) LD (_a+3),A
LD A,(IX+-8) ; 78 v = v + a * dt;
OR A,A LD A,(_dt+3)
JR Z,L_6 LD E,A
; 77 { LD A,(_a+3)
; 78 gravity[0] = false; LD HL,(_dt)
LD (IX+-8),0 CALL __fmul
; 79 x = x - 2; LD H,A
LD IY,(IX+-6) LD A,(_v+3)
LEA IY,IY+-2 LD E,A
LD (IX+-6),IY LD A,H
; 80 } LD HL,(_v)
; 81 else CALL __fadd
JR L_16 LD (_v),BC
L_6: LD (_v+3),A
; 82 { ; 79 u = u + v * dt;
; 83 gravity[0] = true; LD A,(_dt+3)
LD (IX+-8),1 LD E,A
; 84 x = x + 2; LD A,(_v+3)
LD IY,(IX+-6) LD HL,(_dt)
LEA IY,IY+2 CALL __fmul
LD (IX+-6),IY LD H,A
; 85 } LD A,(_u+3)
; 86 } LD E,A
L_16: LD A,H
; 87 LD HL,(_u)
; 88 if ((y + hearts_height) <= LCD_HEIGHT && y >= 0) CALL __fadd
LD IY,(IX+-3) LD (_u),BC
LEA BC,IY+50 LD (_u+3),A
LD HL,240 ; 80 t = t + dt;
OR A,A LD A,(_dt+3)
SBC HL,BC LD E,A
JP M,L_15 LD A,(_t+3)
LD HL,(IX+-3) LD HL,(_dt)
CALL __icmpzero LD BC,(_t)
CALL __setflag CALL __fadd
JP M,L_15 LD (_t),BC
; 89 { LD (_t+3),A
; 90 if (gravity[1]) ; 81
LEA HL,IX+-8 ; 82 if (t * w > LCD_WIDTH)
INC HL LD BC,(_w)
LD A,(HL) CALL __itol
OR A,A CALL __ltof
JR Z,L_11 LD E,A
; 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
LD HL,BC LD HL,BC
LD A,(HL) LD BC,(_t)
OR A,A LD A,(_t+3)
JR Z,L_13 CALL __fmul
; 102 { LD (IX+-4),BC
; 103 gravity[1] = false; LD (IX+-1),A
LD HL,(IX+-11) LD HL,10485760
LD (HL),0 LD E,67
; 104 y = y - 2; CALL __fcmp
LD IY,(IX+-3) JP P,L_8
LEA IY,IY+-2 ; 83 {
LD (IX+-3),IY ; 84 new_card();
; 105 } CALL _new_card
; 106 else ; 85 }
JR L_17 ; 86 else
L_13: JR L_10
; 107 { L_8:
; 108 gravity[1] = true; ; 87 {
LD HL,(IX+-11) ; 88 draw_sprite(t * w, (LCD_HEIGHT - hearts_height) - abs(u));
LD (HL),1 LD BC,(_u)
; 109 y = y + 2; LD A,(_u+3)
LD IY,(IX+-3) CALL __ftol
LEA IY,IY+2
LD (IX+-3),IY
; 110 }
; 111 }
L_17:
; 112
; 113 draw_sprite(x, y);
LD BC,(IX+-3)
PUSH BC 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 PUSH BC
CALL _draw_sprite CALL _draw_sprite
POP BC POP BC
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) LD A,(16056348)
CP A,64 CP A,64
JR NZ,L_18 JR NZ,L_9
; 115 ; 92
; 116 /* Close the graphics */ ; 93 /* Close the graphics */
; 117 gfx_End(); ; 94 gfx_End();
CALL _gfx_End CALL _gfx_End
; 118 } ; 95 }
LD SP,IX LD SP,IX
POP IX POP IX
RET RET
@ -295,42 +469,79 @@ L_17:
;**************************** _main *************************** ;**************************** _main ***************************
;Name Addr/Register Size Type ;Name Addr/Register Size Type
;_gfx_End IMPORT ----- function ;_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 ;_kb_Scan IMPORT ----- function
;_gfx_FillScreen IMPORT ----- function
;_gfx_SetDraw IMPORT ----- function ;_gfx_SetDraw IMPORT ----- function
;_rand IMPORT ----- function ;_logo_gfx_pal IMPORT 12 variable
;_logo_gfx_pal IMPORT 10 variable
;_gfx_SetPalette IMPORT ----- function ;_gfx_SetPalette IMPORT ----- function
;_gfx_Begin IMPORT ----- function ;_gfx_Begin IMPORT ----- function
;_0temp1 STATIC 2 variable ;_srand IMPORT ----- function
;G_0 IX-11 3 variable ;G_0 IX-4 4 variable
;gravity IX-8 2 variable
;x IX-6 3 variable
;y IX-3 3 variable
; Stack Frame Size: 17 (bytes) ; Stack Frame Size: 10 (bytes)
; Spill Code: 0 (instruction) ; Spill Code: 0 (instruction)
SEGMENT TEXT
_0temp1:
DB 1
DB 1
XREF _logo_gfx_pal:ROM XREF _logo_gfx_pal:ROM
XREF _clubs_data:ROM
XREF _spades_data:ROM
XREF _hearts_data:ROM XREF _hearts_data:ROM
XREF _diamonds_data:ROM
XREF _kb_Scan:ROM XREF _kb_Scan:ROM
XREF _gfx_Sprite:ROM XREF _gfx_Sprite:ROM
XREF _gfx_Blit:ROM XREF _gfx_Blit:ROM
XREF _gfx_SetDraw:ROM XREF _gfx_SetDraw:ROM
XREF _gfx_FillScreen:ROM
XREF _gfx_SetPalette:ROM XREF _gfx_SetPalette:ROM
XREF _gfx_End:ROM XREF _gfx_End:ROM
XREF _gfx_Begin:ROM XREF _gfx_Begin:ROM
XREF _abs:ROM
XREF _rand: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 __frameset0:ROM
XREF __frameset:ROM XREF __frameset:ROM
XREF __setflag:ROM XREF __seqcase:ROM
XREF __icmpzero:ROM
XDEF _main XDEF _main
XDEF _new_card
XDEF _draw_sprite 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 END

View File

@ -2,10 +2,11 @@
#include <stdint.h> #include <stdint.h>
#include "logo_gfx.h" #include "logo_gfx.h"
uint16_t logo_gfx_pal[5] = { uint16_t logo_gfx_pal[6] = {
0xFFFF, // 00 :: rgb(255,255,255) 0xFFFF, // 00 :: rgb(255,255,255)
0x0000, // 01 :: rgb(0,0,0) 0x0000, // 01 :: rgb(0,0,0)
0x7C00, // 02 :: rgb(255,0,0) 0x7C00, // 02 :: rgb(255,0,0)
0xEDCF, // 03 :: rgb(221,116,125) 0xEDCF, // 03 :: rgb(221,116,125)
0x0000, // 04 :: rgb(0,0,0) 0x0000, // 04 :: rgb(0,0,0)
0x820B,
}; };

View File

@ -26,7 +26,7 @@ extern uint8_t spades_data[1702];
#define clubs_size 1702 #define clubs_size 1702
extern uint8_t clubs_data[1702]; extern uint8_t clubs_data[1702];
#define clubs ((gfx_sprite_t*)clubs_data) #define clubs ((gfx_sprite_t*)clubs_data)
#define sizeof_logo_gfx_pal 10 #define sizeof_logo_gfx_pal 12
extern uint16_t logo_gfx_pal[5]; extern uint16_t logo_gfx_pal[6];
#endif #endif

View File

@ -14,103 +14,80 @@
/* Include the sprite data */ /* Include the sprite data */
#include "gfx/logo_gfx.h" #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) void draw_sprite(int x, int y)
{ {
/* Fill the screen with color index 0 switch (card)
/* Note that this is a super inefficient way to {
/* redraw, but it demonstrates a simple way of clearing past data */ case 0:
// gfx_FillScreen(0xFF); 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); void new_card()
{
/* Copy the buffer to the screen */ card = randInt(0, 3);
gfx_BlitBuffer(); // This is the same as gfx_Blit(gfx_buffer) 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) void main(void)
{ {
/* Coordinates used for the sprite */ srand(rtc_Time());
int x, y;
bool gravity[2] = {
true,
true};
float angle;
/* Initialize the 8bpp graphics */
gfx_Begin(); gfx_Begin();
/* Set up the palette for our sprites */
gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0); 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_SetDrawBuffer();
gfx_FillScreen(0x05);
//gfx_FillScreen(1); new_card();
draw_sprite(x, y);
do do
{ {
/* Scan the keypad to update kb_Data */ /* Scan the keypad to update kb_Data */
kb_Scan(); 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]) new_card();
{
x = x + 2;
}
else
{
x = x - 2;
}
} }
else else
{ {
if (gravity[0]) draw_sprite(t * w, (LCD_HEIGHT - hearts_height) - abs(u));
{
gravity[0] = false;
x = x - 2;
}
else
{
gravity[0] = true;
x = x + 2;
}
} }
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); } while (kb_Data[6] != kb_Clear);
/* Close the graphics */ /* Close the graphics */