TI-84/obj/main.src

337 lines
6.8 KiB
Plaintext
Raw 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
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(hearts, x, y);
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
; 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
;_hearts_data IMPORT 1702 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 main(void)
; 34 {
_main:
LD HL,-11
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();
CALL _gfx_Begin
; 44
; 45 /* Set up the palette for our sprites */
; 46 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
LD BC,0
PUSH BC
LD BC,10
PUSH BC
LD BC,_logo_gfx_pal
PUSH BC
CALL _gfx_SetPalette
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();
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)
PUSH BC
LD BC,0
PUSH BC
CALL _draw_sprite
POP BC
POP BC
; 57
; 58 do
L_18:
; 59 {
; 60 /* Scan the keypad to update kb_Data */
; 61 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
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)
PUSH BC
LD BC,(IX+-6)
PUSH BC
CALL _draw_sprite
POP BC
POP BC
; 114 } while (kb_Data[6] != kb_Clear);
LD A,(16056348)
CP A,64
JR NZ,L_18
; 115
; 116 /* Close the graphics */
; 117 gfx_End();
CALL _gfx_End
; 118 }
LD SP,IX
POP IX
RET
;**************************** _main ***************************
;Name Addr/Register Size Type
;_gfx_End IMPORT ----- function
;_kb_Scan IMPORT ----- function
;_gfx_SetDraw IMPORT ----- function
;_rand IMPORT ----- function
;_logo_gfx_pal IMPORT 10 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
; Stack Frame Size: 17 (bytes)
; Spill Code: 0 (instruction)
SEGMENT TEXT
_0temp1:
DB 1
DB 1
XREF _logo_gfx_pal:ROM
XREF _hearts_data:ROM
XREF _kb_Scan:ROM
XREF _gfx_Sprite:ROM
XREF _gfx_Blit:ROM
XREF _gfx_SetDraw: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 _draw_sprite
END