TI-84/obj/main.src

391 lines
7.8 KiB
Plaintext
Raw Normal View History

2020-10-11 12:45:50 +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
SEGMENT CODE
; 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
; 17 /* Function for drawing the main sprite */
; 18 void draw_sprite(int x, int y)
; 19 {
_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(dvd, x, y);
LD BC,(IX+9)
PUSH BC
LD BC,(IX+6)
PUSH BC
LD BC,_dvd_data
PUSH BC
CALL _gfx_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)
LD BC,1
PUSH BC
CALL _gfx_Blit
POP BC
; 31 }
LD SP,IX
POP IX
RET
;**************************** _draw_sprite ***************************
;Name Addr/Register Size Type
;_gfx_Blit IMPORT ----- function
;_dvd_data IMPORT 3922 variable
;_gfx_Sprite IMPORT ----- function
;y IX+9 3 parameter
;x IX+6 3 parameter
; Stack Frame Size: 12 (bytes)
; Spill Code: 0 (instruction)
; 32
; 33 void random_palette() {
_random_palette:
; 34 gfx_SetPalette(logo_gfx_pal[randInt(0, 7)], sizeof_logo_gfx_pal, 0);
2020-10-11 12:45:50 +02:00
LD BC,0
PUSH BC
LD BC,86
PUSH BC
CALL _random
LD A,L
AND A,7
UEXT HL
LD L,A
2020-10-11 12:45:50 +02:00
ADD HL,HL
ADD HL,HL
LD BC,_logo_gfx_pal
ADD HL,BC
PUSH HL
CALL _gfx_SetPalette
POP BC
POP BC
POP BC
; 35 }
RET
;**************************** _random_palette ***************************
;Name Addr/Register Size Type
;_random IMPORT ----- function
2020-10-11 12:45:50 +02:00
;_logo_gfx_pal IMPORT 32 variable
;_gfx_SetPalette IMPORT ----- function
; Stack Frame Size: 6 (bytes)
; Spill Code: 0 (instruction)
; 36
; 37 void main(void)
; 38 {
_main:
LD HL,-15
2020-10-11 12:45:50 +02:00
CALL __frameset
; 39 /* Coordinates used for the sprite */
; 40 int x, y;
; 41 int gravity[2];
; 42 float angle;
; 43
; 44 srand(rtc_Time());
LD BC,(15925316)
PUSH BC
CALL _srand
POP BC
; 45
; 46 /* Initialize the 8bpp graphics */
; 47 gfx_Begin();
2020-10-11 12:45:50 +02:00
CALL _gfx_Begin
; 48
; 49 /* Set up the palette for our sprites */
; 50 random_palette();
2020-10-11 12:45:50 +02:00
CALL _random_palette
; 51
; 52 /* Start at 0, 0 */
; 53 x = randInt(0, LCD_WIDTH - dvd_width);
CALL _random
2020-10-11 12:45:50 +02:00
LD BC,241
CALL __iremu
2020-10-11 12:45:50 +02:00
LD (IX+-3),HL
; 54 y = randInt(0, LCD_HEIGHT - dvd_height);
CALL _random
LD BC,192
CALL __iremu
LD (IX+-6),HL
; 55 gravity[0] = randInt(0, 1);
CALL _random
LD A,L
AND A,1
UEXT HL
LD L,A
LD (IX+-12),HL
; 56 gravity[1] = randInt(0, 1);
CALL _random
LD A,L
AND A,1
UEXT HL
LEA IY,IX+-12
LD L,A
; 57
; 58 gfx_SetDrawBuffer();
2020-10-11 12:45:50 +02:00
LD BC,1
PUSH BC
LD (IY+3),HL
2020-10-11 12:45:50 +02:00
CALL _gfx_SetDraw
POP BC
; 59
; 60 gfx_FillScreen(1);
2020-10-11 12:45:50 +02:00
LD BC,1
PUSH BC
CALL _gfx_FillScreen
POP BC
; 61
; 62 draw_sprite(x, y);
LD BC,(IX+-6)
2020-10-11 12:45:50 +02:00
PUSH BC
LD BC,(IX+-3)
2020-10-11 12:45:50 +02:00
PUSH BC
CALL _draw_sprite
POP BC
POP BC
; 63
; 64 do
L_26:
; 65 {
; 66 /* Scan the keypad to update kb_Data */
; 67 kb_Scan();
2020-10-11 12:45:50 +02:00
CALL _kb_Scan
; 68
; 69 if ((x + dvd_width) <= LCD_WIDTH && x >= 0)
LD IY,(IX+-3)
2020-10-11 12:45:50 +02:00
LEA BC,IY+80
LD HL,320
OR A,A
SBC HL,BC
CALL __setflag
JP M,L_12
LD HL,(IX+-3)
2020-10-11 12:45:50 +02:00
CALL __icmpzero
CALL __setflag
JP M,L_12
; 70 {
; 71 if (gravity[0])
LD HL,(IX+-12)
CALL __icmpzero
JR Z,L_6
; 72 {
; 73 x++;
LD BC,(IX+-3)
INC BC
LD (IX+-3),BC
; 74 }
; 75 else
JR L_24
L_6:
; 76 {
; 77 x--;
LD BC,(IX+-3)
DEC BC
LD (IX+-3),BC
; 78 }
; 79 }
; 80 else
JR L_24
L_12:
; 81 {
; 82 random_palette();
CALL _random_palette
; 83 if (gravity[0])
LD HL,(IX+-12)
CALL __icmpzero
JR Z,L_10
; 84 {
; 85 gravity[0] = false;
LD BC,0
LD (IX+-12),BC
; 86 x--;
LD BC,(IX+-3)
DEC BC
LD (IX+-3),BC
; 87 }
; 88 else
JR L_24
L_10:
; 89 {
; 90 gravity[0] = true;
LD BC,1
LD (IX+-12),BC
; 91 x++;
LD BC,(IX+-3)
INC BC
LD (IX+-3),BC
; 92 }
; 93 }
L_24:
; 94
; 95 if ((y + dvd_height) <= LCD_HEIGHT && y >= 0)
LD IY,(IX+-6)
LEA BC,IY+49
LD HL,240
2020-10-11 12:45:50 +02:00
OR A,A
SBC HL,BC
CALL __setflag
JP M,L_23
LD HL,(IX+-6)
CALL __icmpzero
CALL __setflag
JP M,L_23
; 96 {
; 97 if (gravity[1])
LEA HL,IX+-9
LD HL,(HL)
CALL __icmpzero
JR Z,L_17
; 98 {
; 99 y++;
2020-10-11 12:45:50 +02:00
LD BC,(IX+-6)
INC BC
LD (IX+-6),BC
; 100 }
; 101 else
2020-10-11 12:45:50 +02:00
JR L_25
L_17:
; 102 {
; 103 y--;
2020-10-11 12:45:50 +02:00
LD BC,(IX+-6)
DEC BC
LD (IX+-6),BC
; 104 }
; 105 }
; 106 else
2020-10-11 12:45:50 +02:00
JR L_25
L_23:
; 107 {
; 108 random_palette();
2020-10-11 12:45:50 +02:00
CALL _random_palette
; 109 if (gravity[1])
LEA IY,IX+-9
LD (IX+-15),IY
LD HL,(IX+-15)
LD HL,(HL)
CALL __icmpzero
JR Z,L_21
; 110 {
; 111 gravity[1] = false;
LD HL,(IX+-15)
LD BC,0
LD (HL),BC
; 112 y--;
2020-10-11 12:45:50 +02:00
LD BC,(IX+-6)
DEC BC
LD (IX+-6),BC
; 113 }
; 114 else
2020-10-11 12:45:50 +02:00
JR L_25
L_21:
; 115 {
; 116 gravity[1] = true;
LD HL,(IX+-15)
LD BC,1
LD (HL),BC
; 117 y++;
2020-10-11 12:45:50 +02:00
LD BC,(IX+-6)
INC BC
LD (IX+-6),BC
; 118 }
; 119 }
2020-10-11 12:45:50 +02:00
L_25:
; 120
; 121 draw_sprite(x, y);
2020-10-11 12:45:50 +02:00
LD BC,(IX+-6)
PUSH BC
LD BC,(IX+-3)
PUSH BC
2020-10-11 12:45:50 +02:00
CALL _draw_sprite
POP BC
POP BC
; 122 } while (kb_Data[6] != kb_Clear);
2020-10-11 12:45:50 +02:00
LD A,(16056348)
CP A,64
JR NZ,L_26
; 123
; 124 /* Close the graphics */
; 125 gfx_End();
2020-10-11 12:45:50 +02:00
CALL _gfx_End
; 126 }
2020-10-11 12:45:50 +02:00
LD SP,IX
POP IX
RET
;**************************** _main ***************************
;Name Addr/Register Size Type
;_gfx_End IMPORT ----- function
;_kb_Scan IMPORT ----- function
;_gfx_FillScreen IMPORT ----- function
;_gfx_SetDraw IMPORT ----- function
;_random IMPORT ----- function
2020-10-11 12:45:50 +02:00
;_gfx_Begin IMPORT ----- function
;_srand IMPORT ----- function
;G_0 IX-15 3 variable
;gravity IX-12 6 variable
;y IX-6 3 variable
;x IX-3 3 variable
2020-10-11 12:45:50 +02:00
; Stack Frame Size: 21 (bytes)
2020-10-11 12:45:50 +02:00
; Spill Code: 0 (instruction)
XREF _logo_gfx_pal:ROM
XREF _dvd_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 _srand:ROM
XREF _random:ROM
XREF __iremu:ROM
2020-10-11 12:45:50 +02:00
XREF __frameset0:ROM
XREF __frameset:ROM
XREF __setflag:ROM
XREF __icmpzero:ROM
XDEF _main
XDEF _random_palette
XDEF _draw_sprite
END