TI-84/obj/main.src

548 lines
10 KiB
Plaintext
Raw Permalink Normal View History

2020-10-11 12:48:40 +02:00
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM
FILE "SRC\MAIN.C"
.assume ADL=1
2020-10-11 23:43:16 +02:00
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
2020-10-11 12:48:40 +02:00
; 1 #include <stdbool.h>
; 2 #include <stddef.h>
; 3 #include <stdint.h>
; 4 #include <tice.h>
; 5
; 6 #include <math.h>
; 7 #include <stdio.h>
; 8 #include <stdlib.h>
; 9 #include <string.h>
; 10
; 11 #include <graphx.h>
; 12 #include <keypadc.h>
; 13
; 14 /* Include the sprite data */
; 15 #include "gfx/logo_gfx.h"
; 16
2020-10-11 23:43:16 +02:00
; 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 {
2020-10-11 12:48:40 +02:00
_draw_sprite:
CALL __frameset0
2020-10-11 23:43:16 +02:00
; 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);
2020-10-11 12:48:40 +02:00
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
2020-10-11 23:43:16 +02:00
; 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();
2020-10-11 12:48:40 +02:00
LD BC,1
PUSH BC
CALL _gfx_Blit
POP BC
2020-10-11 23:43:16 +02:00
; 39 }
2020-10-11 12:48:40 +02:00
LD SP,IX
POP IX
RET
;**************************** _draw_sprite ***************************
;Name Addr/Register Size Type
;_gfx_Blit IMPORT ----- function
2020-10-11 23:43:16 +02:00
;_clubs_data IMPORT 1702 variable
;_spades_data IMPORT 1702 variable
2020-10-11 12:48:40 +02:00
;_hearts_data IMPORT 1702 variable
2020-10-11 23:43:16 +02:00
;_diamonds_data IMPORT 1702 variable
2020-10-11 12:48:40 +02:00
;_gfx_Sprite IMPORT ----- function
2020-10-11 23:43:16 +02:00
;_card STATIC 3 variable
2020-10-11 12:48:40 +02:00
;y IX+9 3 parameter
;x IX+6 3 parameter
; Stack Frame Size: 12 (bytes)
; Spill Code: 0 (instruction)
2020-10-11 23:43:16 +02:00
; 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 {
2020-10-11 12:48:40 +02:00
_main:
2020-10-11 23:43:16 +02:00
LD HL,-4
2020-10-11 12:48:40 +02:00
CALL __frameset
2020-10-11 23:43:16 +02:00
; 60 srand(rtc_Time());
LD BC,(15925316)
PUSH BC
CALL _srand
POP BC
; 61
; 62 gfx_Begin();
2020-10-11 12:48:40 +02:00
CALL _gfx_Begin
2020-10-11 23:43:16 +02:00
; 63 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
2020-10-11 12:48:40 +02:00
LD BC,0
PUSH BC
2020-10-11 23:43:16 +02:00
LD BC,12
2020-10-11 12:48:40 +02:00
PUSH BC
LD BC,_logo_gfx_pal
PUSH BC
CALL _gfx_SetPalette
POP BC
POP BC
POP BC
2020-10-11 23:43:16 +02:00
; 64 gfx_SetDrawBuffer();
2020-10-11 12:48:40 +02:00
LD BC,1
PUSH BC
CALL _gfx_SetDraw
POP BC
2020-10-11 23:43:16 +02:00
; 65 gfx_FillScreen(0x05);
LD BC,5
2020-10-11 12:48:40 +02:00
PUSH BC
2020-10-11 23:43:16 +02:00
CALL _gfx_FillScreen
2020-10-11 12:48:40 +02:00
POP BC
2020-10-11 23:43:16 +02:00
; 66
; 67 new_card();
CALL _new_card
; 68
; 69 do
L_9:
; 70 {
; 71 /* Scan the keypad to update kb_Data */
; 72 kb_Scan();
2020-10-11 12:48:40 +02:00
CALL _kb_Scan
2020-10-11 23:43:16 +02:00
; 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
2020-10-11 12:48:40 +02:00
L_8:
2020-10-11 23:43:16 +02:00
; 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
2020-10-11 12:48:40 +02:00
OR A,A
SBC HL,BC
2020-10-11 23:43:16 +02:00
PUSH HL
LD BC,(IX+-4)
LD A,(IX+-1)
CALL __ftol
2020-10-11 12:48:40 +02:00
PUSH BC
CALL _draw_sprite
POP BC
POP BC
2020-10-11 23:43:16 +02:00
; 89 }
; 90
; 91 } while (kb_Data[6] != kb_Clear);
L_10:
2020-10-11 12:48:40 +02:00
LD A,(16056348)
CP A,64
2020-10-11 23:43:16 +02:00
JR NZ,L_9
; 92
; 93 /* Close the graphics */
; 94 gfx_End();
2020-10-11 12:48:40 +02:00
CALL _gfx_End
2020-10-11 23:43:16 +02:00
; 95 }
2020-10-11 12:48:40 +02:00
LD SP,IX
POP IX
RET
;**************************** _main ***************************
;Name Addr/Register Size Type
;_gfx_End IMPORT ----- function
2020-10-11 23:43:16 +02:00
;_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
2020-10-11 12:48:40 +02:00
;_kb_Scan IMPORT ----- function
2020-10-11 23:43:16 +02:00
;_gfx_FillScreen IMPORT ----- function
2020-10-11 12:48:40 +02:00
;_gfx_SetDraw IMPORT ----- function
2020-10-11 23:43:16 +02:00
;_logo_gfx_pal IMPORT 12 variable
2020-10-11 12:48:40 +02:00
;_gfx_SetPalette IMPORT ----- function
;_gfx_Begin IMPORT ----- function
2020-10-11 23:43:16 +02:00
;_srand IMPORT ----- function
;G_0 IX-4 4 variable
2020-10-11 12:48:40 +02:00
2020-10-11 23:43:16 +02:00
; Stack Frame Size: 10 (bytes)
2020-10-11 12:48:40 +02:00
; Spill Code: 0 (instruction)
XREF _logo_gfx_pal:ROM
2020-10-11 23:43:16 +02:00
XREF _clubs_data:ROM
XREF _spades_data:ROM
2020-10-11 12:48:40 +02:00
XREF _hearts_data:ROM
2020-10-11 23:43:16 +02:00
XREF _diamonds_data:ROM
2020-10-11 12:48:40 +02:00
XREF _kb_Scan:ROM
XREF _gfx_Sprite:ROM
XREF _gfx_Blit:ROM
XREF _gfx_SetDraw:ROM
2020-10-11 23:43:16 +02:00
XREF _gfx_FillScreen:ROM
2020-10-11 12:48:40 +02:00
XREF _gfx_SetPalette:ROM
XREF _gfx_End:ROM
XREF _gfx_Begin:ROM
2020-10-11 23:43:16 +02:00
XREF _abs:ROM
2020-10-11 12:48:40 +02:00
XREF _rand:ROM
2020-10-11 23:43:16 +02:00
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
2020-10-11 12:48:40 +02:00
XREF __frameset0:ROM
XREF __frameset:ROM
2020-10-11 23:43:16 +02:00
XREF __seqcase:ROM
2020-10-11 12:48:40 +02:00
XDEF _main
2020-10-11 23:43:16 +02:00
XDEF _new_card
2020-10-11 12:48:40 +02:00
XDEF _draw_sprite
2020-10-11 23:43:16 +02:00
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
2020-10-11 12:48:40 +02:00
END