-
Notifications
You must be signed in to change notification settings - Fork 3
/
trex_px4.asm
124 lines (110 loc) · 2.71 KB
/
trex_px4.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
org 100h
; Constants
RBIOS1 equ 00000h
RBIOS2 equ 0EB03h
; BIOS calls
CONIN equ 06h
CONOUT equ 09h
; Starting address of the VRAM
; Should be 8000h or higher and should be in 2k boundary
LSCRVRAM equ 0F294h
; VRAM Y offset (0 .. 63)
LVRAMYOF equ 0F2ADh
; XUSRSCRN
; XSYSSCRN
; Character codes
ESC equ 01Bh
ASTERISK equ 02Ah
TWO equ 032h
THREE equ 033h
start:
; disable cursor
ld a, CONOUT
ld c, ESC
call bios_call
ld a, CONOUT
ld c, TWO
call bios_call
; clear screen
ld a, CONOUT
ld c, ESC
call bios_call
ld a, CONOUT
ld c, ASTERISK
call bios_call
; draw sprite
ld hl, sprite
ld ix, (LSCRVRAM) ; y coord
ld de, 32 ; y offset
ld c, 23 ; sprite height
again:
ld a, (hl)
ld (ix+0), a
inc hl
ld a, (hl)
ld (ix+1), a
inc hl
ld a, (hl)
ld (ix+2), a
inc hl
add ix, de
dec c
jr nz, again
; wait for user input
ld a, CONIN
call bios_call
; clear screen
ld a, CONOUT
ld c, ESC
call bios_call
ld a, CONOUT
ld c, ASTERISK
call bios_call
; enable cursor
ld a, CONOUT
ld c, ESC
call bios_call
ld a, CONOUT
ld c, THREE
call bios_call
ret
; Bios call routine
; A: Bios function number * 3
; return: Depending on BIOS function
; Caution: ROM executable programs should use RBIOS2 instead of RBIOS1
bios_call:
push hl
push de
ld hl, (RBIOS1+1)
ld e, a
ld d, 00h
add hl, de
push hl
pop iy
pop de
pop hl
jp (iy)
sprite:
defb %"--------", %"--------", %"--------"
defb %"--------", %"-------#", %"#######-"
defb %"--------", %"------##", %"-#######"
defb %"--------", %"------##", %"########"
defb %"--------", %"------##", %"########"
defb %"--------", %"------##", %"########"
defb %"--------", %"------##", %"###-----"
defb %"--------", %"------##", %"######--"
defb %"----#---", %"-----###", %"##------"
defb %"----#---", %"---#####", %"##------"
defb %"----##--", %"--######", %"####----"
defb %"----###-", %"-#######", %"##-#----"
defb %"----####", %"########", %"##------"
defb %"----####", %"########", %"##------"
defb %"-----###", %"########", %"#-------"
defb %"------##", %"########", %"#-------"
defb %"-------#", %"########", %"--------"
defb %"--------", %"#######-", %"--------"
defb %"--------", %"-###-##-", %"--------"
defb %"--------", %"-##---#-", %"--------"
defb %"--------", %"-#----#-", %"--------"
defb %"--------", %"-##---##", %"--------"
defb %"--------", %"--------", %"--------"