aboutsummaryrefslogtreecommitdiff
path: root/newtitle.s
blob: ae544817ae224b62d0094dd79b42fc15660e9d83 (plain)
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
; this file needs to be assembled with:
; cl65 -o newtitle.xex -t none newtitle.s
; It contains only an init routine, no run address.

 .include "atari.inc"

 ; where our screen was loaded (see newtitle.pl)
screendata = $3000

 ; homebrew atari xex header
 .word $ffff
 .word start
 .word end-1

 .org $5000 ; anywhere that doesn't step on the title data at
            ; $3000, and doesn't cross a 1K boundary (since there's
            ; a display list included here)

 ; executable code here
start:
 ; setup color registers
 lda #$c0 ; dark green
 sta COLOR2 ; text bg
 lda #$0c ; white
 sta COLOR1

 ; turn off screen, in case vblank happens while we work
 lda #0
 sta SDMCTL

 ; wait for the next frame, to avoid graphics glitching
 jsr wait1jiffy

 ; setup our display list
 lda SDLSTL
 sta FR0
 lda SDLSTH
 sta FR0+1
 lda #<dlist
 sta SDLSTL
 lda #>dlist
 sta SDLSTH

 ; switch to narrow playfield, enable screen
 lda #$21
 sta SDMCTL

 ; clear any keypress that happened during loading
 lda #$ff
 sta CH

 ; wait for user to press a key
wait4key:
 lda CH
 cmp #$ff
 beq wait4key

 ; eat the keypress
 lda #$ff
 sta CH

 ; restore OS's display list
 lda #0
 sta SDMCTL ; disable screen again
 lda FR0
 sta SDLSTL
 lda FR0+1
 sta SDLSTH

 jsr wait1jiffy

 ; switch to normal playfield, enable screen
 lda #$22
 sta SDMCTL

 rts ; return to DOS

wait1jiffy:
 lda RTCLOK+2
wait:
 cmp RTCLOK+2
 beq wait
 rts

 ; display list here
dlist:
 .byte $70 ; 24 scanlines of blanks
 .byte $70
 .byte $70
 .byte $30 ; 4 more since image is only 184 lines tall

 .byte $0f | $40 ; LMS, BASIC mode 8
 .word screendata
 .repeat 127
  .byte $0f ; 127 more scanlines of mode 8
 .endrepeat

 .byte $0f | $40 ; Hit 4K boundary, LMS again
 .word screendata+$1000
 .repeat 55
  .byte $0f ; 55 more scanlines of mode 8
 .endrepeat
 .byte $30 ; blank 4 lines to match GR.8 (does it even matter?)
 .byte $41 ; JVB, jump & wait for vblank
 .word dlist

end:
 .word INITAD
 .word INITAD+1
 .word start