-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmain.asm
More file actions
124 lines (92 loc) · 2.96 KB
/
Copy pathmain.asm
File metadata and controls
124 lines (92 loc) · 2.96 KB
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
;===========================================================================
; main.asm
;===========================================================================
SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION
NEX: equ 1 ; 1=Create nex file, 0=create sna file
IF NEX == 0
;DEVICE ZXSPECTRUM128
DEVICE ZXSPECTRUM48
;DEVICE NOSLOT64K
ELSE
DEVICE ZXSPECTRUMNEXT
ENDIF
ORG 0x4000
defs 0x6000 - $ ; move after screen area
screen_top: defb 0 ; WPMEMx
;===========================================================================
; Persistent watchpoint.
; Change WPMEMx (remove the 'x' from WPMEMx) below to activate.
; If you do so the program will hit a breakpoint when it tries to
; write to the first byte of the 3rd line.
; When program breaks in the fill_memory sub routine please hover over hl
; to see that it contains 0x5804 or COLOR_SCREEN+64.
;===========================================================================
; WPMEMx 0x5840, 1, w
;===========================================================================
; Include modules
;===========================================================================
include "utilities.asm"
include "fill.asm"
include "clearscreen.asm"
; Normally you would assemble the unit tests in a separate target
; in the makefile.
; As this is a very short program and for simplicity the
; unit tests and the main program are assembled in the same binary.
include "unit_tests.asm"
;===========================================================================
; main routine - the code execution starts here.
; Sets up the new interrupt routine, the memory
; banks and jumps to the start loop.
;===========================================================================
defs 0x8000 - $
ORG $8000
main:
; Disable interrupts
di
ld sp,stack_top
; CLS
call clear_screen
call clear_backg
; Init
ld hl,fill_colors
ld (fill_colors_ptr),hl
ld de,COLOR_SCREEN
; Enable interrupts
;im 1
;ei
main_loop:
; fill line with color
ld hl,(fill_colors_ptr)
ld a,(hl)
call fill_bckg_line
; break
push de
ld de,PAUSE_TIME
call pause
pop de
; Alternatively wait on vertical interrupt
;halt
; next line
call inc_fill_colors_ptr
jr main_loop
;===========================================================================
; Stack.
;===========================================================================
; Stack: this area is reserved for the stack
STACK_SIZE: equ 100 ; in words
; Reserve stack space
defw 0 ; WPMEM, 2
stack_bottom:
defs STACK_SIZE*2, 0
stack_top:
;defw 0
defw 0 ; WPMEM, 2
IF NEX == 0
SAVESNA "z80-sample-program.sna", main
ELSE
SAVENEX OPEN "z80-sample-program.nex", main, stack_top
SAVENEX CORE 3, 1, 5
SAVENEX CFG 7 ; Border color
SAVENEX AUTO
SAVENEX CLOSE
ENDIF