1009 lines
18 KiB
NASM
1009 lines
18 KiB
NASM
;--------------------------------------------------------
|
|
; File Created by SDCC : free open source ANSI-C Compiler
|
|
; Version 4.0.0 #11528 (Linux)
|
|
;--------------------------------------------------------
|
|
.module main
|
|
.optsdcc -mz80
|
|
|
|
;--------------------------------------------------------
|
|
; Public variables in this module
|
|
;--------------------------------------------------------
|
|
.globl _main
|
|
.globl _loop
|
|
.globl _draw
|
|
.globl _render
|
|
.globl _new_shape
|
|
.globl _does_piece_fit
|
|
.globl _initialize_field
|
|
.globl _rotate
|
|
.globl _construct_shapes
|
|
.globl _random
|
|
.globl _put_string
|
|
.globl _counter
|
|
.globl _current_y
|
|
.globl _current_x
|
|
.globl _current_rotation
|
|
.globl _current_shape
|
|
.globl _seed
|
|
.globl _screen
|
|
.globl _field
|
|
.globl _tetromino
|
|
;--------------------------------------------------------
|
|
; special function registers
|
|
;--------------------------------------------------------
|
|
_cout = 0x0002
|
|
_status = 0x001f
|
|
_key = 0x001e
|
|
;--------------------------------------------------------
|
|
; ram data
|
|
;--------------------------------------------------------
|
|
.area _DATA
|
|
_tetromino::
|
|
.ds 14
|
|
_field::
|
|
.ds 216
|
|
_screen::
|
|
.ds 216
|
|
_seed::
|
|
.ds 1
|
|
;--------------------------------------------------------
|
|
; ram data
|
|
;--------------------------------------------------------
|
|
.area _INITIALIZED
|
|
_current_shape::
|
|
.ds 1
|
|
_current_rotation::
|
|
.ds 1
|
|
_current_x::
|
|
.ds 1
|
|
_current_y::
|
|
.ds 1
|
|
_counter::
|
|
.ds 1
|
|
;--------------------------------------------------------
|
|
; absolute external ram data
|
|
;--------------------------------------------------------
|
|
.area _DABS (ABS)
|
|
;--------------------------------------------------------
|
|
; global & static initialisations
|
|
;--------------------------------------------------------
|
|
.area _HOME
|
|
.area _GSINIT
|
|
.area _GSFINAL
|
|
.area _GSINIT
|
|
;--------------------------------------------------------
|
|
; Home
|
|
;--------------------------------------------------------
|
|
.area _HOME
|
|
.area _HOME
|
|
;--------------------------------------------------------
|
|
; code
|
|
;--------------------------------------------------------
|
|
.area _CODE
|
|
;src/main.c:12: void construct_shapes() {
|
|
; ---------------------------------
|
|
; Function construct_shapes
|
|
; ---------------------------------
|
|
_construct_shapes::
|
|
;src/main.c:13: tetromino[0] = "..X."
|
|
ld hl, #___str_0
|
|
ld (_tetromino), hl
|
|
;src/main.c:18: tetromino[1] = "..X."
|
|
ld hl, #___str_1
|
|
ld ((_tetromino + 0x0002)), hl
|
|
;src/main.c:23: tetromino[2] = ".X.."
|
|
ld hl, #___str_2
|
|
ld ((_tetromino + 0x0004)), hl
|
|
;src/main.c:28: tetromino[3] = "..X."
|
|
ld hl, #___str_3
|
|
ld ((_tetromino + 0x0006)), hl
|
|
;src/main.c:33: tetromino[4] = ".X.."
|
|
ld hl, #___str_4
|
|
ld ((_tetromino + 0x0008)), hl
|
|
;src/main.c:38: tetromino[5] = "..X."
|
|
ld hl, #___str_5
|
|
ld ((_tetromino + 0x000a)), hl
|
|
;src/main.c:43: tetromino[6] = "...."
|
|
ld hl, #___str_6
|
|
ld ((_tetromino + 0x000c)), hl
|
|
;src/main.c:47: }
|
|
ret
|
|
___str_0:
|
|
.ascii "..X...X...X...X."
|
|
.db 0x00
|
|
___str_1:
|
|
.ascii "..X..XX..X......"
|
|
.db 0x00
|
|
___str_2:
|
|
.ascii ".X...XX...X....."
|
|
.db 0x00
|
|
___str_3:
|
|
.ascii "..X...X..XX....."
|
|
.db 0x00
|
|
___str_4:
|
|
.ascii ".X...X...XX....."
|
|
.db 0x00
|
|
___str_5:
|
|
.ascii "..X..XX...X....."
|
|
.db 0x00
|
|
___str_6:
|
|
.ascii ".....XX..XX....."
|
|
.db 0x00
|
|
;src/main.c:49: uint8_t rotate(uint8_t x, uint8_t y, uint8_t r) {
|
|
; ---------------------------------
|
|
; Function rotate
|
|
; ---------------------------------
|
|
_rotate::
|
|
push ix
|
|
ld ix,#0
|
|
add ix,sp
|
|
dec sp
|
|
;src/main.c:52: return y*4+x;
|
|
ld a, 5 (ix)
|
|
ld c, 4 (ix)
|
|
add a, a
|
|
add a, a
|
|
ld l, a
|
|
;src/main.c:50: switch (r) {
|
|
ld a, 6 (ix)
|
|
or a, a
|
|
jr Z,00101$
|
|
;src/main.c:54: return 12 + y - x*4;
|
|
ld e, 5 (ix)
|
|
ld a, 4 (ix)
|
|
add a, a
|
|
add a, a
|
|
ld -1 (ix), a
|
|
;src/main.c:50: switch (r) {
|
|
ld a, 6 (ix)
|
|
dec a
|
|
jr Z,00102$
|
|
ld a, 6 (ix)
|
|
sub a, #0x02
|
|
jr Z,00103$
|
|
ld a, 6 (ix)
|
|
sub a, #0x03
|
|
jr Z,00104$
|
|
jr 00105$
|
|
;src/main.c:51: case 0:
|
|
00101$:
|
|
;src/main.c:52: return y*4+x;
|
|
add hl, bc
|
|
jr 00106$
|
|
;src/main.c:53: case 1:
|
|
00102$:
|
|
;src/main.c:54: return 12 + y - x*4;
|
|
ld a, e
|
|
add a, #0x0c
|
|
sub a, -1 (ix)
|
|
ld l, a
|
|
jr 00106$
|
|
;src/main.c:55: case 2:
|
|
00103$:
|
|
;src/main.c:56: return 15 - y*4 - x;
|
|
ld a, #0x0f
|
|
sub a, l
|
|
sub a, c
|
|
ld l, a
|
|
jr 00106$
|
|
;src/main.c:57: case 3:
|
|
00104$:
|
|
;src/main.c:58: return 3 - y + x*4;
|
|
ld a, #0x03
|
|
sub a, e
|
|
add a, -1 (ix)
|
|
ld l, a
|
|
jr 00106$
|
|
;src/main.c:59: }
|
|
00105$:
|
|
;src/main.c:60: return 0;
|
|
ld l, #0x00
|
|
00106$:
|
|
;src/main.c:61: }
|
|
inc sp
|
|
pop ix
|
|
ret
|
|
;src/main.c:63: void initialize_field() {
|
|
; ---------------------------------
|
|
; Function initialize_field
|
|
; ---------------------------------
|
|
_initialize_field::
|
|
push ix
|
|
ld ix,#0
|
|
add ix,sp
|
|
push af
|
|
dec sp
|
|
;src/main.c:64: for (uint8_t y = 0; y < HEIGHT; ++y) {
|
|
ld c, #0x00
|
|
00107$:
|
|
;src/main.c:65: for (uint8_t x = 0; x < WIDTH; ++x) {
|
|
ld a,c
|
|
cp a,#0x12
|
|
jr NC,00109$
|
|
sub a, #0x11
|
|
ld a, #0x01
|
|
jr Z,00153$
|
|
xor a, a
|
|
00153$:
|
|
ld -3 (ix), a
|
|
ld e, #0x00
|
|
00104$:
|
|
ld a, e
|
|
sub a, #0x0c
|
|
jr NC,00108$
|
|
;src/main.c:66: field[y*WIDTH + x] = (x == 0 || x == WIDTH - 1 || y == HEIGHT-1) ? 9 : 0;
|
|
ld l, c
|
|
ld h, #0x00
|
|
push de
|
|
ld e, l
|
|
ld d, h
|
|
add hl, hl
|
|
add hl, de
|
|
add hl, hl
|
|
add hl, hl
|
|
pop de
|
|
ld a, e
|
|
ld d, #0x00
|
|
add a, l
|
|
ld l, a
|
|
ld a, d
|
|
adc a, h
|
|
ld h, a
|
|
ld a, l
|
|
add a, #<(_field)
|
|
ld -2 (ix), a
|
|
ld a, h
|
|
adc a, #>(_field)
|
|
ld -1 (ix), a
|
|
ld a, e
|
|
or a, a
|
|
jr Z,00114$
|
|
ld a, e
|
|
sub a, #0x0b
|
|
jr Z,00114$
|
|
bit 0, -3 (ix)
|
|
jr Z,00111$
|
|
00114$:
|
|
ld hl, #0x0009
|
|
jr 00112$
|
|
00111$:
|
|
ld hl, #0x0000
|
|
00112$:
|
|
ld a, l
|
|
ld l, -2 (ix)
|
|
ld h, -1 (ix)
|
|
ld (hl), a
|
|
;src/main.c:65: for (uint8_t x = 0; x < WIDTH; ++x) {
|
|
inc e
|
|
jr 00104$
|
|
00108$:
|
|
;src/main.c:64: for (uint8_t y = 0; y < HEIGHT; ++y) {
|
|
inc c
|
|
jr 00107$
|
|
00109$:
|
|
;src/main.c:69: }
|
|
ld sp, ix
|
|
pop ix
|
|
ret
|
|
;src/main.c:71: uint8_t does_piece_fit(uint8_t shape, uint8_t rotation, uint8_t px, uint8_t py) {
|
|
; ---------------------------------
|
|
; Function does_piece_fit
|
|
; ---------------------------------
|
|
_does_piece_fit::
|
|
push ix
|
|
ld ix,#0
|
|
add ix,sp
|
|
push af
|
|
push af
|
|
;src/main.c:72: for (uint8_t y = 0; y < 4; ++y) {
|
|
ld c, #0x00
|
|
00116$:
|
|
ld a, c
|
|
sub a, #0x04
|
|
jp NC, 00111$
|
|
;src/main.c:73: for (uint8_t x = 0; x < 4; ++x) {
|
|
ld a, 7 (ix)
|
|
add a, c
|
|
ld -4 (ix), a
|
|
xor a, a
|
|
ld -1 (ix), a
|
|
00113$:
|
|
ld a, -1 (ix)
|
|
sub a, #0x04
|
|
jp NC, 00117$
|
|
;src/main.c:75: uint8_t pi = rotate(x, y, rotation);
|
|
push bc
|
|
ld b, 5 (ix)
|
|
push bc
|
|
ld a, -1 (ix)
|
|
push af
|
|
inc sp
|
|
call _rotate
|
|
pop af
|
|
inc sp
|
|
pop bc
|
|
ld -3 (ix), l
|
|
;src/main.c:78: uint8_t fi = (py + y) * WIDTH + px + x;
|
|
ld a, -4 (ix)
|
|
ld e, a
|
|
add a, a
|
|
add a, e
|
|
add a, a
|
|
add a, a
|
|
ld b, 6 (ix)
|
|
add a, b
|
|
ld b, -1 (ix)
|
|
add a, b
|
|
ld -2 (ix), a
|
|
;src/main.c:80: if (px + x >= 0 && px + x < WIDTH) {
|
|
ld e, 6 (ix)
|
|
ld d, #0x00
|
|
ld l, -1 (ix)
|
|
ld h, #0x00
|
|
add hl, de
|
|
bit 7, h
|
|
jr NZ,00114$
|
|
ld de, #0x800c
|
|
add hl, hl
|
|
ccf
|
|
rr h
|
|
rr l
|
|
sbc hl, de
|
|
jr NC,00114$
|
|
;src/main.c:81: if (py + y >= 0 && py + y < HEIGHT) {
|
|
ld e, 7 (ix)
|
|
ld d, #0x00
|
|
ld l, c
|
|
ld h, #0x00
|
|
add hl, de
|
|
bit 7, h
|
|
jr NZ,00114$
|
|
ld de, #0x8012
|
|
add hl, hl
|
|
ccf
|
|
rr h
|
|
rr l
|
|
sbc hl, de
|
|
jr NC,00114$
|
|
;src/main.c:83: if (tetromino[shape][pi] == 'X' && field[fi] != 0) {
|
|
ld l, 4 (ix)
|
|
ld h, #0x00
|
|
add hl, hl
|
|
ld de, #_tetromino
|
|
add hl, de
|
|
ld e, (hl)
|
|
inc hl
|
|
ld d, (hl)
|
|
ld l, -3 (ix)
|
|
ld h, #0x00
|
|
add hl, de
|
|
ld a, (hl)
|
|
sub a, #0x58
|
|
jr NZ,00114$
|
|
ld a, -2 (ix)
|
|
add a, #<(_field)
|
|
ld e, a
|
|
ld a, #0x00
|
|
adc a, #>(_field)
|
|
ld d, a
|
|
ld a, (de)
|
|
or a, a
|
|
jr Z,00114$
|
|
;src/main.c:84: return 0;
|
|
ld l, #0x00
|
|
jr 00118$
|
|
00114$:
|
|
;src/main.c:73: for (uint8_t x = 0; x < 4; ++x) {
|
|
inc -1 (ix)
|
|
jp 00113$
|
|
00117$:
|
|
;src/main.c:72: for (uint8_t y = 0; y < 4; ++y) {
|
|
inc c
|
|
jp 00116$
|
|
00111$:
|
|
;src/main.c:91: return 1;
|
|
ld l, #0x01
|
|
00118$:
|
|
;src/main.c:92: }
|
|
ld sp, ix
|
|
pop ix
|
|
ret
|
|
;src/main.c:99: void new_shape() {
|
|
; ---------------------------------
|
|
; Function new_shape
|
|
; ---------------------------------
|
|
_new_shape::
|
|
;src/main.c:100: do {
|
|
00101$:
|
|
;src/main.c:101: current_shape = random() & 0x07;
|
|
call _random
|
|
ld a, l
|
|
and a, #0x07
|
|
ld (_current_shape+0), a
|
|
;src/main.c:102: } while (current_shape == 7);
|
|
ld a,(#_current_shape + 0)
|
|
sub a, #0x07
|
|
jr Z,00101$
|
|
;src/main.c:103: }
|
|
ret
|
|
;src/main.c:105: void render() {
|
|
; ---------------------------------
|
|
; Function render
|
|
; ---------------------------------
|
|
_render::
|
|
push ix
|
|
ld ix,#0
|
|
add ix,sp
|
|
push af
|
|
push af
|
|
;src/main.c:107: for (uint8_t i = 0; i < WIDTH*HEIGHT; ++i) {
|
|
ld bc, #_screen+0
|
|
ld de, #_field+0
|
|
xor a, a
|
|
ld -1 (ix), a
|
|
00107$:
|
|
ld a, -1 (ix)
|
|
sub a, #0xd8
|
|
jr NC,00101$
|
|
;src/main.c:108: screen[i] = field[i];
|
|
ld a, c
|
|
add a, -1 (ix)
|
|
ld -3 (ix), a
|
|
ld a, b
|
|
adc a, #0x00
|
|
ld -2 (ix), a
|
|
ld l, -1 (ix)
|
|
ld h, #0x00
|
|
add hl, de
|
|
ld a, (hl)
|
|
ld l, -3 (ix)
|
|
ld h, -2 (ix)
|
|
ld (hl), a
|
|
;src/main.c:107: for (uint8_t i = 0; i < WIDTH*HEIGHT; ++i) {
|
|
inc -1 (ix)
|
|
jr 00107$
|
|
00101$:
|
|
;src/main.c:112: for (uint8_t y = 0; y < 4; ++y) {
|
|
ld e, #0x00
|
|
00113$:
|
|
ld a, e
|
|
sub a, #0x04
|
|
jp NC, 00115$
|
|
;src/main.c:113: for (uint8_t x = 0; x < 4; ++x) {
|
|
ld d, #0x00
|
|
00110$:
|
|
ld a, d
|
|
sub a, #0x04
|
|
jp NC, 00114$
|
|
;src/main.c:114: if (tetromino[current_shape][rotate(x, y, current_rotation)] == 'X') {
|
|
ld iy, #_current_shape
|
|
ld l, 0 (iy)
|
|
ld h, #0x00
|
|
add hl, hl
|
|
ld a, #<(_tetromino)
|
|
add a, l
|
|
ld l, a
|
|
ld a, #>(_tetromino)
|
|
adc a, h
|
|
ld h, a
|
|
ld a, (hl)
|
|
ld -2 (ix), a
|
|
inc hl
|
|
ld a, (hl)
|
|
ld -1 (ix), a
|
|
push bc
|
|
push de
|
|
ld a, (_current_rotation)
|
|
push af
|
|
inc sp
|
|
ld a, e
|
|
push af
|
|
inc sp
|
|
push de
|
|
inc sp
|
|
call _rotate
|
|
pop af
|
|
inc sp
|
|
ld a, l
|
|
pop de
|
|
pop bc
|
|
add a, -2 (ix)
|
|
ld l, a
|
|
ld a, #0x00
|
|
adc a, -1 (ix)
|
|
ld h, a
|
|
ld a, (hl)
|
|
sub a, #0x58
|
|
jr NZ,00111$
|
|
;src/main.c:115: screen[(current_y+y)*WIDTH + current_x + x] = current_shape + 1;
|
|
ld iy, #_current_y
|
|
ld l, 0 (iy)
|
|
ld h, #0x00
|
|
ld -2 (ix), e
|
|
xor a, a
|
|
ld -1 (ix), a
|
|
ld a, -2 (ix)
|
|
add a, l
|
|
ld l, a
|
|
ld a, -1 (ix)
|
|
adc a, h
|
|
ld h, a
|
|
push de
|
|
ld e, l
|
|
ld d, h
|
|
add hl, hl
|
|
add hl, de
|
|
add hl, hl
|
|
add hl, hl
|
|
pop de
|
|
ex (sp), hl
|
|
ld a,(#_current_x + 0)
|
|
ld h, #0x00
|
|
add a, -4 (ix)
|
|
ld -2 (ix), a
|
|
ld a, h
|
|
adc a, -3 (ix)
|
|
ld -1 (ix), a
|
|
ld l, d
|
|
ld h, #0x00
|
|
ld a, l
|
|
add a, -2 (ix)
|
|
ld l, a
|
|
ld a, h
|
|
adc a, -1 (ix)
|
|
ld h, a
|
|
add hl, bc
|
|
ld -2 (ix), l
|
|
ld -1 (ix), h
|
|
ld a,(#_current_shape + 0)
|
|
inc a
|
|
ld l, -2 (ix)
|
|
ld h, -1 (ix)
|
|
ld (hl), a
|
|
00111$:
|
|
;src/main.c:113: for (uint8_t x = 0; x < 4; ++x) {
|
|
inc d
|
|
jp 00110$
|
|
00114$:
|
|
;src/main.c:112: for (uint8_t y = 0; y < 4; ++y) {
|
|
inc e
|
|
jp 00113$
|
|
00115$:
|
|
;src/main.c:119: }
|
|
ld sp, ix
|
|
pop ix
|
|
ret
|
|
;src/main.c:122: void draw() {
|
|
; ---------------------------------
|
|
; Function draw
|
|
; ---------------------------------
|
|
_draw::
|
|
push ix
|
|
ld ix,#0
|
|
add ix,sp
|
|
dec sp
|
|
;src/main.c:124: put_string("\033[2;2H");
|
|
ld hl, #___str_8
|
|
push hl
|
|
call _put_string
|
|
pop af
|
|
;src/main.c:125: for (uint8_t y = 0; y < HEIGHT*SCALE; ++y) {
|
|
ld c, #0x00
|
|
00112$:
|
|
ld a, c
|
|
sub a, #0x12
|
|
jr NC,00114$
|
|
;src/main.c:126: for (uint8_t x = 0; x < WIDTH*SCALE; ++x) {
|
|
xor a, a
|
|
ld -1 (ix), a
|
|
00109$:
|
|
ld a, -1 (ix)
|
|
sub a, #0x0c
|
|
jr NC,00106$
|
|
;src/main.c:127: uint8_t i = screen[y/SCALE*WIDTH + x/SCALE];
|
|
ld e, c
|
|
ld d, #0x00
|
|
ld l, e
|
|
ld h, d
|
|
add hl, hl
|
|
add hl, de
|
|
add hl, hl
|
|
add hl, hl
|
|
ld e, -1 (ix)
|
|
ld d, #0x00
|
|
add hl, de
|
|
ld de, #_screen
|
|
add hl, de
|
|
ld e, (hl)
|
|
;src/main.c:128: if (i >= 8) {
|
|
ld a, e
|
|
sub a, #0x08
|
|
jr C,00104$
|
|
;src/main.c:129: cout = '\033';
|
|
ld a, #0x1b
|
|
out (_cout), a
|
|
;src/main.c:130: cout = '[';
|
|
ld a, #0x5b
|
|
out (_cout), a
|
|
;src/main.c:131: cout = '0';
|
|
ld a, #0x30
|
|
out (_cout), a
|
|
;src/main.c:132: cout = 'm';
|
|
ld a, #0x6d
|
|
out (_cout), a
|
|
jr 00105$
|
|
00104$:
|
|
;src/main.c:133: } else if (i > 0) {
|
|
ld a, e
|
|
or a, a
|
|
jr Z,00105$
|
|
;src/main.c:134: cout = '\033';
|
|
ld a, #0x1b
|
|
out (_cout), a
|
|
;src/main.c:135: cout = '[';
|
|
ld a, #0x5b
|
|
out (_cout), a
|
|
;src/main.c:136: cout = '3';
|
|
ld a, #0x33
|
|
out (_cout), a
|
|
;src/main.c:137: cout = 48+i;
|
|
ld a, e
|
|
add a, #0x30
|
|
out (_cout), a
|
|
;src/main.c:138: cout = 'm';
|
|
ld a, #0x6d
|
|
out (_cout), a
|
|
00105$:
|
|
;src/main.c:140: char c = " RGOBMCW=#"[i];
|
|
ld hl, #___str_7
|
|
ld d, #0x00
|
|
add hl, de
|
|
ld a, (hl)
|
|
out (_cout), a
|
|
;src/main.c:126: for (uint8_t x = 0; x < WIDTH*SCALE; ++x) {
|
|
inc -1 (ix)
|
|
jr 00109$
|
|
00106$:
|
|
;src/main.c:143: cout = '\n';
|
|
ld a, #0x0a
|
|
out (_cout), a
|
|
;src/main.c:144: cout = '\r';
|
|
ld a, #0x0d
|
|
out (_cout), a
|
|
;src/main.c:145: cout = ' ';
|
|
ld a, #0x20
|
|
out (_cout), a
|
|
;src/main.c:125: for (uint8_t y = 0; y < HEIGHT*SCALE; ++y) {
|
|
inc c
|
|
jr 00112$
|
|
00114$:
|
|
;src/main.c:147: }
|
|
inc sp
|
|
pop ix
|
|
ret
|
|
___str_7:
|
|
.ascii " RGOBMCW=#"
|
|
.db 0x00
|
|
___str_8:
|
|
.db 0x1b
|
|
.ascii "[2;2H"
|
|
.db 0x00
|
|
;src/main.c:154: uint8_t loop() {
|
|
; ---------------------------------
|
|
; Function loop
|
|
; ---------------------------------
|
|
_loop::
|
|
push ix
|
|
ld ix,#0
|
|
add ix,sp
|
|
push af
|
|
;src/main.c:156: if (status & 1) {
|
|
in a, (_status)
|
|
rrca
|
|
jp NC,00116$
|
|
;src/main.c:157: uint8_t nx = current_x;
|
|
ld a,(#_current_x + 0)
|
|
ld -2 (ix), a
|
|
;src/main.c:158: uint8_t ny = current_y;
|
|
ld hl,#_current_y + 0
|
|
ld c, (hl)
|
|
;src/main.c:159: uint8_t nr = current_rotation;
|
|
ld a,(#_current_rotation + 0)
|
|
ld -1 (ix), a
|
|
;src/main.c:161: switch (key) {
|
|
in a, (_key)
|
|
cp a, #0x03
|
|
jr Z,00101$
|
|
cp a, #0x61
|
|
jr Z,00102$
|
|
cp a, #0x64
|
|
jr Z,00103$
|
|
cp a, #0x72
|
|
jr Z,00104$
|
|
cp a, #0x73
|
|
jr Z,00107$
|
|
sub a, #0x77
|
|
jr Z,00142$
|
|
jr 00112$
|
|
;src/main.c:162: case 0x03:
|
|
00101$:
|
|
;src/main.c:163: put_string("Exit!\n\r");
|
|
ld hl, #___str_9
|
|
push hl
|
|
call _put_string
|
|
pop af
|
|
;src/main.c:164: return 0;
|
|
ld l, #0x00
|
|
jp 00132$
|
|
;src/main.c:167: case 'a':
|
|
00102$:
|
|
;src/main.c:168: nx--;
|
|
dec -2 (ix)
|
|
;src/main.c:169: break;
|
|
jr 00112$
|
|
;src/main.c:172: case 'd':
|
|
00103$:
|
|
;src/main.c:173: nx++;
|
|
inc -2 (ix)
|
|
;src/main.c:174: break;
|
|
jr 00112$
|
|
;src/main.c:177: case 'r':
|
|
00104$:
|
|
;src/main.c:178: nr++;
|
|
inc -1 (ix)
|
|
;src/main.c:179: if (nr == 4) {
|
|
ld a, -1 (ix)
|
|
sub a, #0x04
|
|
jr NZ,00112$
|
|
;src/main.c:180: nr = 0;
|
|
xor a, a
|
|
ld -1 (ix), a
|
|
;src/main.c:182: break;
|
|
jr 00112$
|
|
;src/main.c:185: case 's':
|
|
00107$:
|
|
;src/main.c:186: counter = 0;
|
|
ld hl,#_counter + 0
|
|
ld (hl), #0x00
|
|
;src/main.c:187: break;
|
|
jr 00112$
|
|
;src/main.c:191: while (does_piece_fit(current_shape, current_rotation, current_x, ++ny + 1));
|
|
00142$:
|
|
00109$:
|
|
inc c
|
|
ld a, c
|
|
inc a
|
|
push bc
|
|
push af
|
|
inc sp
|
|
ld a, (_current_x)
|
|
push af
|
|
inc sp
|
|
ld a, (_current_rotation)
|
|
push af
|
|
inc sp
|
|
ld a, (_current_shape)
|
|
push af
|
|
inc sp
|
|
call _does_piece_fit
|
|
pop af
|
|
pop af
|
|
ld a, l
|
|
pop bc
|
|
or a, a
|
|
jr NZ,00109$
|
|
;src/main.c:193: }
|
|
00112$:
|
|
;src/main.c:195: if (does_piece_fit(current_shape, nr, nx, ny)) {
|
|
push bc
|
|
ld a, c
|
|
push af
|
|
inc sp
|
|
ld h, -2 (ix)
|
|
ld l, -1 (ix)
|
|
push hl
|
|
ld a, (_current_shape)
|
|
push af
|
|
inc sp
|
|
call _does_piece_fit
|
|
pop af
|
|
pop af
|
|
ld a, l
|
|
pop bc
|
|
or a, a
|
|
jr Z,00116$
|
|
;src/main.c:196: current_x = nx;
|
|
ld a, -2 (ix)
|
|
ld (#_current_x + 0),a
|
|
;src/main.c:197: current_y = ny;
|
|
ld hl,#_current_y + 0
|
|
ld (hl), c
|
|
;src/main.c:198: current_rotation = nr;
|
|
ld a, -1 (ix)
|
|
ld (#_current_rotation + 0),a
|
|
00116$:
|
|
;src/main.c:203: if (counter == 0) {
|
|
ld a,(#_counter + 0)
|
|
or a, a
|
|
jp NZ, 00125$
|
|
;src/main.c:204: if (does_piece_fit(current_shape, current_rotation, current_x, current_y+1)) {
|
|
ld a,(#_current_y + 0)
|
|
inc a
|
|
push af
|
|
inc sp
|
|
ld a, (_current_x)
|
|
push af
|
|
inc sp
|
|
ld a, (_current_rotation)
|
|
push af
|
|
inc sp
|
|
ld a, (_current_shape)
|
|
push af
|
|
inc sp
|
|
call _does_piece_fit
|
|
pop af
|
|
pop af
|
|
ld a, l
|
|
or a, a
|
|
jr Z,00150$
|
|
;src/main.c:205: current_y++;
|
|
ld hl, #_current_y+0
|
|
inc (hl)
|
|
jp 00123$
|
|
;src/main.c:208: for (uint8_t y = 0; y < 4; ++y) {
|
|
00150$:
|
|
ld c, #0x00
|
|
00130$:
|
|
ld a, c
|
|
sub a, #0x04
|
|
jr NC,00120$
|
|
;src/main.c:209: for (uint8_t x = 0; x < 4; ++x) {
|
|
ld b, #0x00
|
|
00127$:
|
|
ld a, b
|
|
sub a, #0x04
|
|
jr NC,00131$
|
|
;src/main.c:210: if (tetromino[current_shape][rotate(x, y, current_rotation)] == 'X') {
|
|
ld iy, #_current_shape
|
|
ld l, 0 (iy)
|
|
ld h, #0x00
|
|
add hl, hl
|
|
ld de, #_tetromino
|
|
add hl, de
|
|
ld e, (hl)
|
|
inc hl
|
|
ld d, (hl)
|
|
push bc
|
|
push de
|
|
ld a, (_current_rotation)
|
|
push af
|
|
inc sp
|
|
ld a, c
|
|
push af
|
|
inc sp
|
|
push bc
|
|
inc sp
|
|
call _rotate
|
|
pop af
|
|
inc sp
|
|
pop de
|
|
pop bc
|
|
ld h, #0x00
|
|
add hl, de
|
|
ld a, (hl)
|
|
sub a, #0x58
|
|
jr NZ,00128$
|
|
;src/main.c:211: field[(current_y+y)*WIDTH + current_x + x] = current_shape + 1;
|
|
ld hl,#_current_y + 0
|
|
ld e, (hl)
|
|
ld d, #0x00
|
|
ld l, c
|
|
ld h, #0x00
|
|
add hl, de
|
|
ld e, l
|
|
ld d, h
|
|
add hl, hl
|
|
add hl, de
|
|
add hl, hl
|
|
add hl, hl
|
|
ex de, hl
|
|
ld iy, #_current_x
|
|
ld l, 0 (iy)
|
|
ld h, #0x00
|
|
add hl, de
|
|
ld e, b
|
|
ld d, #0x00
|
|
add hl, de
|
|
ex de, hl
|
|
ld hl, #_field
|
|
add hl, de
|
|
ex de, hl
|
|
ld a,(#_current_shape + 0)
|
|
inc a
|
|
ld (de), a
|
|
00128$:
|
|
;src/main.c:209: for (uint8_t x = 0; x < 4; ++x) {
|
|
inc b
|
|
jr 00127$
|
|
00131$:
|
|
;src/main.c:208: for (uint8_t y = 0; y < 4; ++y) {
|
|
inc c
|
|
jr 00130$
|
|
00120$:
|
|
;src/main.c:216: new_shape();
|
|
call _new_shape
|
|
;src/main.c:217: current_y = 0;
|
|
ld hl,#_current_y + 0
|
|
ld (hl), #0x00
|
|
;src/main.c:218: current_x = WIDTH/2;
|
|
ld hl,#_current_x + 0
|
|
ld (hl), #0x06
|
|
;src/main.c:219: current_rotation = 0;
|
|
ld hl,#_current_rotation + 0
|
|
ld (hl), #0x00
|
|
00123$:
|
|
;src/main.c:221: counter = SPEED;
|
|
ld hl,#_counter + 0
|
|
ld (hl), #0x02
|
|
00125$:
|
|
;src/main.c:224: counter--;
|
|
ld hl, #_counter+0
|
|
dec (hl)
|
|
;src/main.c:226: render();
|
|
call _render
|
|
;src/main.c:227: draw();
|
|
call _draw
|
|
;src/main.c:229: return 1;
|
|
ld l, #0x01
|
|
00132$:
|
|
;src/main.c:230: }
|
|
ld sp, ix
|
|
pop ix
|
|
ret
|
|
___str_9:
|
|
.ascii "Exit!"
|
|
.db 0x0a
|
|
.db 0x0d
|
|
.db 0x00
|
|
;src/main.c:234: void main() {
|
|
; ---------------------------------
|
|
; Function main
|
|
; ---------------------------------
|
|
_main::
|
|
;src/main.c:235: construct_shapes();
|
|
call _construct_shapes
|
|
;src/main.c:236: initialize_field();
|
|
call _initialize_field
|
|
;src/main.c:239: new_shape();
|
|
call _new_shape
|
|
;src/main.c:242: put_string("\033[2J");
|
|
ld hl, #___str_10
|
|
push hl
|
|
call _put_string
|
|
pop af
|
|
;src/main.c:246: while (loop());
|
|
00101$:
|
|
call _loop
|
|
ld a, l
|
|
or a, a
|
|
jr NZ,00101$
|
|
;src/main.c:247: }
|
|
ret
|
|
___str_10:
|
|
.db 0x1b
|
|
.ascii "[2J"
|
|
.db 0x00
|
|
.area _CODE
|
|
.area _INITIALIZER
|
|
__xinit__current_shape:
|
|
.db #0x00 ; 0
|
|
__xinit__current_rotation:
|
|
.db #0x00 ; 0
|
|
__xinit__current_x:
|
|
.db #0x06 ; 6
|
|
__xinit__current_y:
|
|
.db #0x00 ; 0
|
|
__xinit__counter:
|
|
.db #0x02 ; 2
|
|
.area _CABS (ABS)
|