TI-84/obj/main.src

373 lines
7.5 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[(rand() % (7 - 0 + 1))], sizeof_logo_gfx_pal, 0);
LD BC,0
PUSH BC
LD BC,86
PUSH BC
CALL _rand
LD BC,8
CALL __irems
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
;_rand IMPORT ----- function
;_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,-11
CALL __frameset
; 39 /* Coordinates used for the sprite */
; 40 int x, y;
; 41 bool gravity[2] = {
; 42 true,
; 43 true
; 44 };
LEA DE,IX+-8
LD HL,_0temp2
LD BC,2
LDIR
; 45 float angle;
; 46
; 47 /* Initialize the 8bpp graphics */
; 48 gfx_Begin();
CALL _gfx_Begin
; 49
; 50 /* Set up the palette for our sprites */
; 51 random_palette();
CALL _random_palette
; 52
; 53 /* Start at 0, 0 */
; 54 x = 0;
LD BC,0
LD (IX+-6),BC
; 55 y = (rand() % (LCD_HEIGHT - 0 + 1));
CALL _rand
LD BC,241
CALL __irems
LD (IX+-3),HL
; 56
; 57 gfx_SetDrawBuffer();
LD BC,1
PUSH BC
CALL _gfx_SetDraw
POP BC
; 58
; 59 gfx_FillScreen(1);
LD BC,1
PUSH BC
CALL _gfx_FillScreen
POP BC
; 60
; 61 draw_sprite(x, y);
LD BC,(IX+-3)
PUSH BC
LD BC,0
PUSH BC
CALL _draw_sprite
POP BC
POP BC
; 62
; 63 do
L_27:
; 64 {
; 65 /* Scan the keypad to update kb_Data */
; 66 kb_Scan();
CALL _kb_Scan
; 67
; 68 if ((x + dvd_width) <= LCD_WIDTH && x >= 0)
LD IY,(IX+-6)
LEA BC,IY+80
LD HL,320
OR A,A
SBC HL,BC
CALL __setflag
JP M,L_13
LD HL,(IX+-6)
CALL __icmpzero
CALL __setflag
JP M,L_13
; 69 {
; 70 if (gravity[0])
LD A,(IX+-8)
OR A,A
JR Z,L_7
; 71 {
; 72 x++;
LD BC,(IX+-6)
INC BC
LD (IX+-6),BC
; 73 }
; 74 else
JR L_25
L_7:
; 75 {
; 76 x--;
LD BC,(IX+-6)
DEC BC
LD (IX+-6),BC
; 77 }
; 78 }
; 79 else
JR L_25
L_13:
; 80 {
; 81 random_palette();
CALL _random_palette
; 82 if (gravity[0])
LD A,(IX+-8)
OR A,A
JR Z,L_11
; 83 {
; 84 gravity[0] = false;
LD (IX+-8),0
; 85 x--;
LD BC,(IX+-6)
DEC BC
LD (IX+-6),BC
; 86 }
; 87 else
JR L_25
L_11:
; 88 {
; 89 gravity[0] = true;
LD (IX+-8),1
; 90 x++;
LD BC,(IX+-6)
INC BC
LD (IX+-6),BC
; 91 }
; 92 }
L_25:
; 93
; 94 if ((y + dvd_height) <= LCD_HEIGHT && y >= 0)
LD IY,(IX+-3)
LEA BC,IY+49
LD HL,240
OR A,A
SBC HL,BC
JP M,L_24
LD HL,(IX+-3)
CALL __icmpzero
CALL __setflag
JP M,L_24
; 95 {
; 96 if (gravity[1])
LEA HL,IX+-8
INC HL
LD A,(HL)
OR A,A
JR Z,L_18
; 97 {
; 98 y++;
LD BC,(IX+-3)
INC BC
LD (IX+-3),BC
; 99 }
; 100 else
JR L_26
L_18:
; 101 {
; 102 y--;
LD BC,(IX+-3)
DEC BC
LD (IX+-3),BC
; 103 }
; 104 }
; 105 else
JR L_26
L_24:
; 106 {
; 107 random_palette();
CALL _random_palette
; 108 if (gravity[1])
LEA BC,IX+-8
INC BC
LD (IX+-11),BC
LD HL,BC
LD A,(HL)
OR A,A
JR Z,L_22
; 109 {
; 110 gravity[1] = false;
LD HL,(IX+-11)
LD (HL),0
; 111 y--;
LD BC,(IX+-3)
DEC BC
LD (IX+-3),BC
; 112 }
; 113 else
JR L_26
L_22:
; 114 {
; 115 gravity[1] = true;
LD HL,(IX+-11)
LD (HL),1
; 116 y++;
LD BC,(IX+-3)
INC BC
LD (IX+-3),BC
; 117 }
; 118 }
L_26:
; 119
; 120 draw_sprite(x, y);
LD BC,(IX+-3)
PUSH BC
LD BC,(IX+-6)
PUSH BC
CALL _draw_sprite
POP BC
POP BC
; 121 } while (kb_Data[6] != kb_Clear);
LD A,(16056348)
CP A,64
JR NZ,L_27
; 122
; 123 /* Close the graphics */
; 124 gfx_End();
CALL _gfx_End
; 125 }
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
;_rand IMPORT ----- function
;_gfx_Begin IMPORT ----- function
;_0temp2 STATIC 2 variable
;G_0 IX-11 3 variable
;gravity IX-8 2 variable
;x IX-6 3 variable
;y IX-3 3 variable
; Stack Frame Size: 17 (bytes)
; Spill Code: 0 (instruction)
SEGMENT TEXT
_0temp2:
DB 1
DB 1
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 _rand:ROM
XREF __irems:ROM
XREF __frameset0:ROM
XREF __frameset:ROM
XREF __setflag:ROM
XREF __icmpzero:ROM
XDEF _main
XDEF _random_palette
XDEF _draw_sprite
END