mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-20 01:29:36 +00:00
vgi: work on doom
This commit is contained in:
parent
598eb22da7
commit
84b997651d
|
@ -7,10 +7,11 @@ EMPTYDISK = ../../../empty_disk/empty.dsk
|
||||||
|
|
||||||
all: vgi_myst.dsk make_boxes_asm
|
all: vgi_myst.dsk make_boxes_asm
|
||||||
|
|
||||||
vgi_myst.dsk: HELLO VGI-MYST
|
vgi_myst.dsk: HELLO VGI-MYST VGI-DOOM
|
||||||
cp $(EMPTYDISK) vgi_myst.dsk
|
cp $(EMPTYDISK) vgi_myst.dsk
|
||||||
$(DOS33) -y vgi_myst.dsk SAVE A HELLO
|
$(DOS33) -y vgi_myst.dsk SAVE A HELLO
|
||||||
$(DOS33) -y vgi_myst.dsk BSAVE -a 0xC00 VGI-MYST
|
$(DOS33) -y vgi_myst.dsk BSAVE -a 0xC00 VGI-MYST
|
||||||
|
$(DOS33) -y vgi_myst.dsk BSAVE -a 0x4000 VGI-DOOM
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -29,6 +30,23 @@ myst_vgi.o: clock.data rocket.data rocket_door.data red_book.data fireplace.data
|
||||||
vgi_triangles.s
|
vgi_triangles.s
|
||||||
ca65 -o myst_vgi.o myst_vgi.s -l myst_vgi.lst
|
ca65 -o myst_vgi.o myst_vgi.s -l myst_vgi.lst
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
VGI-DOOM: doom_vgi.o
|
||||||
|
ld65 -o VGI-DOOM doom_vgi.o -C $(LINKERSCRIPTS)/apple2_4000.inc
|
||||||
|
|
||||||
|
doom_vgi.o: doom.data \
|
||||||
|
doom_vgi.s vgi_clearscreen.s vgi_rectangle.s vgi_circles.s vgi_lines.s \
|
||||||
|
vgi_triangles.s
|
||||||
|
ca65 -o doom_vgi.o doom_vgi.s -l doom_vgi.lst
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
doom.data: make_boxes_asm doom.vgi
|
||||||
|
echo "doom_data:" > doom.data
|
||||||
|
./make_boxes_asm < doom.vgi >> doom.data
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
@ -79,4 +97,4 @@ make_boxes_asm.o: make_boxes_asm.c
|
||||||
###
|
###
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ *.o *.lst HELLO VGI-MYST make_boxes_asm *.data
|
rm -f *~ *.o *.lst HELLO VGI-MYST VGI-DOOM make_boxes_asm *.data
|
||||||
|
|
|
@ -161,6 +161,15 @@ VGI Line (10)
|
||||||
|
|
||||||
The last point you draw is the starting point for LINETO
|
The last point you draw is the starting point for LINETO
|
||||||
|
|
||||||
|
=============
|
||||||
|
VGI Line Far (11)
|
||||||
|
|
||||||
|
LINE color x1 y1 x2 y2
|
||||||
|
|
||||||
|
Draws a line from (x1,y1)
|
||||||
|
|
||||||
|
In this one X2 must be > 255
|
||||||
|
|
||||||
============
|
============
|
||||||
VGI End (15)
|
VGI End (15)
|
||||||
|
|
||||||
|
|
147
graphics/hgr/vgi/doom.vgi
Normal file
147
graphics/hgr/vgi/doom.vgi
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
; Doom. A bad Idea
|
||||||
|
CLS 0 ; black background
|
||||||
|
; back walls
|
||||||
|
LINE 7 0 99 41 93 ; left
|
||||||
|
LINE 7 0 91 41 90
|
||||||
|
LINE 7 0 77 41 77
|
||||||
|
LINE 7 0 70 41 70
|
||||||
|
LINE 7 69 86 99 86 ; middle
|
||||||
|
LINE 7 69 89 194 89
|
||||||
|
LINE 7 71 74 97 74
|
||||||
|
LINE 2 71 65 98 72 ; upper
|
||||||
|
LINETO 182 72
|
||||||
|
DRECT 0x8 0x22 160 62 173 66 ; green blobs
|
||||||
|
DRECT 0x8 0x22 144 63 153 65
|
||||||
|
DRECT 0x8 0x22 90 57 97 64
|
||||||
|
; white walls
|
||||||
|
RECT 7 7 183 60 278 72 ; top white wall
|
||||||
|
LINE 4 183 67 211 67 ; top bricks
|
||||||
|
LINE 4 191 67 191 60
|
||||||
|
LINE 4 199 67 199 60
|
||||||
|
LINE 4 208 77 208 57
|
||||||
|
RECT 7 7 241 59 278 109 ; right white wall
|
||||||
|
LINE 4 241 63 255 60 ; going down
|
||||||
|
LINE 4 241 68 255 68
|
||||||
|
LINE 4 241 73 255 72
|
||||||
|
LINE 4 241 85 255 85
|
||||||
|
LINE 4 241 92 255 92
|
||||||
|
LINE 4 279 102 241 94
|
||||||
|
LINEF 4 256 60 256 107 ; vertical
|
||||||
|
LINEF 4 259 60 259 96
|
||||||
|
LINEF 4 262 60 262 96
|
||||||
|
LINEF 4 265 60 265 96
|
||||||
|
LINEF 4 268 60 268 96
|
||||||
|
LINEF 5 274 60 274 96
|
||||||
|
LINEF 4 268 67 279 67 ; horizontal
|
||||||
|
LINEF 4 268 72 279 72
|
||||||
|
LINEF 4 269 74 279 74
|
||||||
|
LINEF 4 269 80 279 80
|
||||||
|
LINEF 4 269 83 279 83
|
||||||
|
LINEF 4 269 86 279 86
|
||||||
|
LINEF 4 269 94 279 94
|
||||||
|
LINEF 4 256 97 279 97
|
||||||
|
LINEF 4 268 100 268 108
|
||||||
|
; back pillars
|
||||||
|
RECT 5 5 97 59 106 98 ; left back
|
||||||
|
RECT 5 5 173 57 184 99 ; right back
|
||||||
|
RECT 5 5 97 93 212 98 ; floor
|
||||||
|
LINE 6 107 96 174 95 ; blue line
|
||||||
|
; pool
|
||||||
|
RECT 6 6 106 98 232 109 ; pool rectangle
|
||||||
|
VTRI 6 106 98 83 106 109 ; pool l triangle
|
||||||
|
VTRI 6 225 98 225 255 109 ; pool r triangle
|
||||||
|
LINE 6 256 109 225 98 ; pool r triangle
|
||||||
|
LINE 6 257 109 225 98 ; pool r triangle
|
||||||
|
LINE 6 258 109 225 98 ; pool r triangle
|
||||||
|
LINE 6 259 109 225 98 ; pool r triangle
|
||||||
|
VTRI 6 95 96 60 74 109 ; l step
|
||||||
|
VTRI 6 74 109 97 104 96 ; l step
|
||||||
|
VTRI 5 74 109 104 107 96 ; orange step
|
||||||
|
VTRI 5 104 98 74 82 109 ; orange step
|
||||||
|
VTRI 5 96 94 65 72 104
|
||||||
|
LINE 5 72 104 90 95 96
|
||||||
|
; barrel
|
||||||
|
DRECT 0x8 0x22 236 94 250 107 ; green barrel
|
||||||
|
; carnage?
|
||||||
|
RECT 2 5 118 100 139 105 ; ???
|
||||||
|
; front pillars
|
||||||
|
RECT 4 5 39 59 60 110 ; left front (shade)
|
||||||
|
RECT 5 5 59 59 71 110 ; left front
|
||||||
|
RECT 5 5 209 59 221 110 ; right front (shade)
|
||||||
|
RECT 4 5 221 59 241 110 ; right front
|
||||||
|
; ceiling
|
||||||
|
RECT 4 0 0 0 140 60 ; ceiling left
|
||||||
|
RECT 4 0 140 0 279 60 ; ceiling right
|
||||||
|
LINE 7 279 59 0 59 ; border
|
||||||
|
LINE 7 16 59 0 54 ; forward
|
||||||
|
LINE 7 44 59 0 47
|
||||||
|
LINE 7 69 59 0 38
|
||||||
|
LINE 7 85 59 0 20
|
||||||
|
LINE 7 110 59 32 0
|
||||||
|
LINE 7 133 59 107 0
|
||||||
|
LINE 7 152 59 183 0
|
||||||
|
LINEF 7 179 59 258 0
|
||||||
|
LINEF 7 197 59 279 22
|
||||||
|
LINEF 7 219 59 279 37
|
||||||
|
LINEF 7 239 59 279 47
|
||||||
|
LINE 7 64 24 116 24 ; horiz front
|
||||||
|
LINE 7 169 24 226 24 ; horiz front
|
||||||
|
LINE 7 35 35 75 35 ; middle
|
||||||
|
LINE 7 123 35 166 35 ; middle
|
||||||
|
LINE 7 211 35 250 35 ; middle
|
||||||
|
LINE 7 39 49 65 49
|
||||||
|
LINE 7 98 49 127 49
|
||||||
|
LINE 7 159 49 191 49
|
||||||
|
LINE 7 221 49 248 49
|
||||||
|
LINE 7 19 52 47 52 ; back
|
||||||
|
LINE 7 72 52 102 52
|
||||||
|
LINE 7 130 52 155 52
|
||||||
|
LINE 7 188 52 212 52
|
||||||
|
LINEF 7 236 52 262 52
|
||||||
|
; floor hexes
|
||||||
|
; front row
|
||||||
|
LINE 7 0 160 46 146 ; left
|
||||||
|
LINETO 72 147
|
||||||
|
LINETO 86 160
|
||||||
|
LINE 7 149 147 166 147
|
||||||
|
LINETO 198 160
|
||||||
|
LINETO 224 160
|
||||||
|
LINETO 233 147
|
||||||
|
LINEF 7 233 147 260 147
|
||||||
|
LINEF 7 260 147 279 152
|
||||||
|
; second row
|
||||||
|
LINE 7 0 136 39 138
|
||||||
|
LINETO 46 147
|
||||||
|
LINE 7 70 147 99 136
|
||||||
|
LINETO 122 139
|
||||||
|
LINETO 134 145
|
||||||
|
LINE 7 150 147 165 147
|
||||||
|
LINETO 179 136
|
||||||
|
LINETO 201 136
|
||||||
|
LINETO 233 146
|
||||||
|
LINEF 7 258 147 261 136
|
||||||
|
LINEF 7 261 136 279 136
|
||||||
|
; third row
|
||||||
|
LINE 7 40 138 59 132
|
||||||
|
LINETO 91 130
|
||||||
|
LINETO 98 137
|
||||||
|
LINE 7 122 137 139 131
|
||||||
|
LINETO 160 131
|
||||||
|
LINETO 178 137
|
||||||
|
LINE 7 202 137 209 130
|
||||||
|
LINETO 233 131
|
||||||
|
LINEF 7 233 131 261 137
|
||||||
|
; hand
|
||||||
|
FCIRC 5 139 166 23 ; hand
|
||||||
|
LINE 4 118 150 119 161 ; hand line
|
||||||
|
VTRI 4 157 154 156 161 161 ; hand line
|
||||||
|
LINE 4 126 148 127 153 ; hand line
|
||||||
|
LINETO 135 157
|
||||||
|
FCIRC 7 140 140 11 ; gun
|
||||||
|
FCIRC 7 140 122 5 ; gun
|
||||||
|
FCIRC 4 140 127 5 ; gun
|
||||||
|
FCIRC 4 140 140 7 ; gun
|
||||||
|
LINE 4 140 117 140 123 ; sight
|
||||||
|
LINE 7 135 124 130 137 ;
|
||||||
|
LINE 7 146 124 151 137
|
||||||
|
END
|
BIN
graphics/hgr/vgi/doom_e1m1.pt3
Normal file
BIN
graphics/hgr/vgi/doom_e1m1.pt3
Normal file
Binary file not shown.
424
graphics/hgr/vgi/doom_vgi.s
Normal file
424
graphics/hgr/vgi/doom_vgi.s
Normal file
|
@ -0,0 +1,424 @@
|
||||||
|
; VGI Doom
|
||||||
|
|
||||||
|
.include "zp.inc"
|
||||||
|
.include "hardware.inc"
|
||||||
|
|
||||||
|
VGI_MAXLEN = 7
|
||||||
|
|
||||||
|
PT3_LOC = doom_e1_m1
|
||||||
|
|
||||||
|
PT3_ENABLE_APPLE_IIC = 1
|
||||||
|
|
||||||
|
|
||||||
|
vgi_doom:
|
||||||
|
; Init variables
|
||||||
|
lda #0
|
||||||
|
sta DONE_PLAYING
|
||||||
|
lda #1
|
||||||
|
sta LOOP ; loop forever
|
||||||
|
|
||||||
|
;=======================
|
||||||
|
; Detect Apple II Model
|
||||||
|
;========================
|
||||||
|
; IRQ setup is different on IIc
|
||||||
|
; You can possibly skip this if you only care about II+/IIe
|
||||||
|
|
||||||
|
.ifdef PT3_ENABLE_APPLE_IIC
|
||||||
|
jsr detect_appleii_model
|
||||||
|
.endif
|
||||||
|
|
||||||
|
;=======================
|
||||||
|
; Detect mockingboard
|
||||||
|
;========================
|
||||||
|
|
||||||
|
jsr print_mockingboard_detect ; print message
|
||||||
|
|
||||||
|
jsr mockingboard_detect ; call detection routine
|
||||||
|
|
||||||
|
bcs mockingboard_found
|
||||||
|
|
||||||
|
jsr print_mocking_notfound
|
||||||
|
|
||||||
|
; possibly can't detect on IIc so just try with slot#4 anyway
|
||||||
|
; even if not detected
|
||||||
|
|
||||||
|
jmp setup_interrupt
|
||||||
|
|
||||||
|
mockingboard_found:
|
||||||
|
|
||||||
|
; print found message
|
||||||
|
; modify message to print slot value
|
||||||
|
|
||||||
|
lda MB_ADDR_H
|
||||||
|
sec
|
||||||
|
sbc #$10
|
||||||
|
sta found_message+11
|
||||||
|
|
||||||
|
jsr print_mocking_found
|
||||||
|
|
||||||
|
;==================================================
|
||||||
|
; patch the playing code with the proper slot value
|
||||||
|
;==================================================
|
||||||
|
|
||||||
|
jsr mockingboard_patch
|
||||||
|
|
||||||
|
setup_interrupt:
|
||||||
|
|
||||||
|
;=======================
|
||||||
|
; Set up 50Hz interrupt
|
||||||
|
;========================
|
||||||
|
|
||||||
|
jsr mockingboard_init
|
||||||
|
jsr mockingboard_setup_interrupt
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; Init the Mockingboard
|
||||||
|
;============================
|
||||||
|
|
||||||
|
jsr reset_ay_both
|
||||||
|
jsr clear_ay_both
|
||||||
|
|
||||||
|
;==================
|
||||||
|
; init song
|
||||||
|
;==================
|
||||||
|
|
||||||
|
jsr pt3_init_song
|
||||||
|
|
||||||
|
|
||||||
|
jsr SETGR
|
||||||
|
jsr HGR
|
||||||
|
; bit FULLGR
|
||||||
|
|
||||||
|
jsr make_tables
|
||||||
|
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; Enable 6502 interrupts
|
||||||
|
;============================
|
||||||
|
start_interrupts:
|
||||||
|
cli ; clear interrupt mask
|
||||||
|
|
||||||
|
|
||||||
|
; get pointer to image data
|
||||||
|
|
||||||
|
lda #<doom_data
|
||||||
|
sta VGIL
|
||||||
|
lda #>doom_data
|
||||||
|
sta VGIH
|
||||||
|
|
||||||
|
; lda #<clock_data
|
||||||
|
; sta VGIL
|
||||||
|
; lda #>clock_data
|
||||||
|
; sta VGIH
|
||||||
|
|
||||||
|
jsr play_vgi
|
||||||
|
|
||||||
|
jsr wait_until_keypress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
jsr CROUT1 ; print linefeed/cr
|
||||||
|
|
||||||
|
loopy:
|
||||||
|
lda #<string1
|
||||||
|
sta OUTL
|
||||||
|
lda #>string1
|
||||||
|
sta OUTH
|
||||||
|
|
||||||
|
jsr fake_input
|
||||||
|
jsr fake_input
|
||||||
|
jsr fake_input
|
||||||
|
|
||||||
|
done:
|
||||||
|
jmp done
|
||||||
|
|
||||||
|
|
||||||
|
;==================================
|
||||||
|
; play_vgi
|
||||||
|
;==================================
|
||||||
|
play_vgi:
|
||||||
|
|
||||||
|
vgi_loop:
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
data_smc:
|
||||||
|
lda (VGIL),Y
|
||||||
|
sta VGI_BUFFER,Y
|
||||||
|
iny
|
||||||
|
cpy #VGI_MAXLEN
|
||||||
|
bne data_smc
|
||||||
|
|
||||||
|
lda TYPE
|
||||||
|
and #$f
|
||||||
|
|
||||||
|
clc
|
||||||
|
adc VGIL
|
||||||
|
sta VGIL
|
||||||
|
bcc no_oflo
|
||||||
|
inc VGIH
|
||||||
|
no_oflo:
|
||||||
|
|
||||||
|
lda TYPE
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
|
||||||
|
; look up action in jump table
|
||||||
|
asl
|
||||||
|
tax
|
||||||
|
lda vgi_rts_table+1,X
|
||||||
|
pha
|
||||||
|
lda vgi_rts_table,X
|
||||||
|
pha
|
||||||
|
rts ; "jump" to subroutine
|
||||||
|
|
||||||
|
vgi_rts_table:
|
||||||
|
.word vgi_clearscreen-1 ; 0 = clearscreen
|
||||||
|
.word vgi_simple_rectangle-1 ; 1 = simple rectangle
|
||||||
|
.word vgi_circle-1 ; 2 = plain circle
|
||||||
|
.word vgi_filled_circle-1 ; 3 = filled circle
|
||||||
|
.word vgi_point-1 ; 4 = dot
|
||||||
|
.word vgi_lineto-1 ; 5 = line to
|
||||||
|
.word vgi_dithered_rectangle-1 ; 6 = dithered rectangle
|
||||||
|
.word vgi_vertical_triangle-1 ; 7 = vertical triangle
|
||||||
|
.word vgi_horizontal_triangle-1 ; 8 = horizontal triangle
|
||||||
|
.word vgi_vstripe_rectangle-1 ; 9 = vstripe rectangle
|
||||||
|
.word vgi_line-1 ;10 = line
|
||||||
|
.word vgi_line_far-1 ;11 = line far
|
||||||
|
.word all_done-1
|
||||||
|
.word all_done-1
|
||||||
|
.word all_done-1
|
||||||
|
.word all_done-1 ; 15 = done
|
||||||
|
|
||||||
|
all_done:
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
.include "vgi_clearscreen.s"
|
||||||
|
.include "vgi_circles.s"
|
||||||
|
.include "vgi_rectangle.s"
|
||||||
|
.include "vgi_lines.s"
|
||||||
|
.include "vgi_triangles.s"
|
||||||
|
|
||||||
|
.include "doom.data"
|
||||||
|
|
||||||
|
; string data
|
||||||
|
;
|
||||||
|
|
||||||
|
string1:
|
||||||
|
.byte "YOU SEE A CLOCK TOWER READING 12:00",13
|
||||||
|
.byte " LEFT/RIGHT/FORWARD",13,0
|
||||||
|
|
||||||
|
; SWIM TO TOWER
|
||||||
|
string2:
|
||||||
|
.byte "YOU DON'T KNOW HOW TO ",34,"SWIM",34,13,0
|
||||||
|
|
||||||
|
; WADE TO TOWER
|
||||||
|
string3:
|
||||||
|
.byte "THE KRAKEN WILL EAT YOU",13,0
|
||||||
|
|
||||||
|
; I AM WILLING TO TAKE THAT RISK
|
||||||
|
|
||||||
|
string4:
|
||||||
|
.byte "YOU SEE A MYSTERIOUS SPACESHIP",13
|
||||||
|
.byte " LEFT/RIGHT/FORWARD",13,0
|
||||||
|
|
||||||
|
string5:
|
||||||
|
.byte "YOU ARE CLOSE TO THE SPACESHIP",13
|
||||||
|
.byte "YOU SEE A DOOR",13,0
|
||||||
|
|
||||||
|
; OPEN DOOR
|
||||||
|
|
||||||
|
string6:
|
||||||
|
.byte "THE DOOR IS LOCKED",13
|
||||||
|
.byte "ATRUS HATES YOU",13,0
|
||||||
|
|
||||||
|
;string7:
|
||||||
|
;.byte "SORRY, I DON'T UNDERSTAND THAT",0
|
||||||
|
|
||||||
|
string7:
|
||||||
|
.byte "YOU SEE A RED BOOK",13
|
||||||
|
.byte "NEXT TO IT IS A PAGE",13,0
|
||||||
|
|
||||||
|
string8:
|
||||||
|
.byte "WHICH PAGE?",13,0
|
||||||
|
|
||||||
|
string9:
|
||||||
|
.byte "I'D SAY IT'S MORE OF A PURPLE COLOR",13,0
|
||||||
|
|
||||||
|
string10:
|
||||||
|
.byte "THIS IS A MOST UNUSUAL FIREPLACE",13
|
||||||
|
.byte "THERE ARE MANY BUTTONS HERE",13,0
|
||||||
|
|
||||||
|
string11:
|
||||||
|
.byte "WHICH BUTTON?",13,0
|
||||||
|
|
||||||
|
string12:
|
||||||
|
.byte "THAT WAS NOT THE RIGHT ONE",13,0
|
||||||
|
|
||||||
|
; PICK UP PAGE
|
||||||
|
; WHICH PAGE?
|
||||||
|
; THE RED ONE
|
||||||
|
; I'D SAY IT'S MORE OF A PURPLE COLOR
|
||||||
|
; JUST PICK IT UP!
|
||||||
|
|
||||||
|
; THIS WEIRD FIREPLACE HAS MANY BUTTONS
|
||||||
|
|
||||||
|
; PRESS BUTTON
|
||||||
|
|
||||||
|
; WHICH ONE?
|
||||||
|
|
||||||
|
; REALLY?
|
||||||
|
|
||||||
|
; WHICH ONE (0..126)
|
||||||
|
|
||||||
|
; NOTHING HAPPENS
|
||||||
|
|
||||||
|
;=========================
|
||||||
|
; print_string
|
||||||
|
;=========================
|
||||||
|
print_string:
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
print_string_loop:
|
||||||
|
lda (OUTL),Y
|
||||||
|
beq done_print_string
|
||||||
|
|
||||||
|
ora #$80
|
||||||
|
jsr COUT
|
||||||
|
|
||||||
|
iny
|
||||||
|
|
||||||
|
jmp print_string_loop
|
||||||
|
|
||||||
|
done_print_string:
|
||||||
|
tya ; point to next string
|
||||||
|
sec
|
||||||
|
adc OUTL
|
||||||
|
sta OUTL
|
||||||
|
lda OUTH
|
||||||
|
adc #0
|
||||||
|
sta OUTH
|
||||||
|
rts
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; WAIT UNTIL KEYPRESS
|
||||||
|
;============================
|
||||||
|
|
||||||
|
wait_until_keypress:
|
||||||
|
|
||||||
|
lda KEYPRESS
|
||||||
|
bpl wait_until_keypress
|
||||||
|
|
||||||
|
bit KEYRESET
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
;=============================
|
||||||
|
; fake input
|
||||||
|
;=============================
|
||||||
|
fake_input:
|
||||||
|
jsr print_string
|
||||||
|
|
||||||
|
jsr CROUT1 ; print linefeed/cr
|
||||||
|
|
||||||
|
lda #'>'+$80
|
||||||
|
jsr COUT
|
||||||
|
lda #' '+$80
|
||||||
|
jsr COUT
|
||||||
|
|
||||||
|
jsr GETLN1
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
.ifdef PT3_ENABLE_APPLE_IIC
|
||||||
|
.include "pt3_lib_detect_model.s"
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.include "pt3_lib_core.s"
|
||||||
|
.include "pt3_lib_init.s"
|
||||||
|
.include "pt3_lib_mockingboard_setup.s"
|
||||||
|
.include "interrupt_handler.s"
|
||||||
|
; if you're self patching, detect has to be after interrupt_handler.s
|
||||||
|
.include "pt3_lib_mockingboard_detect.s"
|
||||||
|
|
||||||
|
|
||||||
|
;==================================
|
||||||
|
; Print mockingboard detect message
|
||||||
|
;==================================
|
||||||
|
; note: on IIc must do this before enabling interrupt
|
||||||
|
; as we disable ROM (COUT won't work?)
|
||||||
|
|
||||||
|
print_mockingboard_detect:
|
||||||
|
lda APPLEII_MODEL
|
||||||
|
sta apple_message+17
|
||||||
|
|
||||||
|
; print detection message for Apple II type
|
||||||
|
ldy #0
|
||||||
|
print_apple_message:
|
||||||
|
lda apple_message,Y ; load loading message
|
||||||
|
beq done_apple_message
|
||||||
|
ora #$80
|
||||||
|
jsr COUT
|
||||||
|
iny
|
||||||
|
jmp print_apple_message
|
||||||
|
done_apple_message:
|
||||||
|
jsr CROUT1
|
||||||
|
|
||||||
|
|
||||||
|
; print detection message
|
||||||
|
ldy #0
|
||||||
|
print_mocking_message:
|
||||||
|
lda mocking_message,Y ; load loading message
|
||||||
|
beq done_mocking_message
|
||||||
|
ora #$80
|
||||||
|
jsr COUT
|
||||||
|
iny
|
||||||
|
jmp print_mocking_message
|
||||||
|
done_mocking_message:
|
||||||
|
jsr CROUT1
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
print_mocking_notfound:
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
print_not_message:
|
||||||
|
lda not_message,Y ; load loading message
|
||||||
|
beq print_not_message_done
|
||||||
|
ora #$80
|
||||||
|
jsr COUT
|
||||||
|
iny
|
||||||
|
jmp print_not_message
|
||||||
|
print_not_message_done:
|
||||||
|
rts
|
||||||
|
|
||||||
|
print_mocking_found:
|
||||||
|
ldy #0
|
||||||
|
print_found_message:
|
||||||
|
lda found_message,Y ; load loading message
|
||||||
|
beq done_found_message
|
||||||
|
ora #$80
|
||||||
|
jsr COUT
|
||||||
|
iny
|
||||||
|
jmp print_found_message
|
||||||
|
done_found_message:
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
;=========
|
||||||
|
; strings
|
||||||
|
;=========
|
||||||
|
apple_message: .asciiz "DETECTED APPLE II "
|
||||||
|
|
||||||
|
mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD: "
|
||||||
|
not_message: .byte "NOT "
|
||||||
|
found_message: .asciiz "FOUND SLOT#4"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.align $100
|
||||||
|
doom_e1_m1:
|
||||||
|
.incbin "doom_e1m1.pt3"
|
69
graphics/hgr/vgi/interrupt_handler.s
Normal file
69
graphics/hgr/vgi/interrupt_handler.s
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
;================================
|
||||||
|
;================================
|
||||||
|
; mockingboard interrupt handler
|
||||||
|
;================================
|
||||||
|
;================================
|
||||||
|
; On Apple II/6502 the interrupt handler jumps to address in 0xfffe
|
||||||
|
; This is in the ROM, which saves the registers
|
||||||
|
; on older IIe it saved A to $45 (which could mess with DISK II)
|
||||||
|
; newer IIe doesn't do that.
|
||||||
|
; It then calculates if it is a BRK or not (which trashes A)
|
||||||
|
; Then it sets up the stack like an interrupt and calls 0x3fe
|
||||||
|
|
||||||
|
; Note: the IIc is much more complicated
|
||||||
|
; its firmware tries to decode the proper source
|
||||||
|
; based on various things, including screen hole values
|
||||||
|
; we bypass that by switching out ROM and replacing the
|
||||||
|
; $fffe vector with this, but that does mean we have
|
||||||
|
; to be sure status flag and accumulator set properly
|
||||||
|
|
||||||
|
interrupt_handler:
|
||||||
|
php ; save status flags
|
||||||
|
cld ; clear decimal mode
|
||||||
|
pha ; save A ; 3
|
||||||
|
; A is saved in $45 by firmware
|
||||||
|
txa
|
||||||
|
pha ; save X
|
||||||
|
tya
|
||||||
|
pha ; save Y
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; inc $0404 ; debug (flashes char onscreen)
|
||||||
|
|
||||||
|
|
||||||
|
.include "pt3_lib_irq_handler.s"
|
||||||
|
|
||||||
|
jmp exit_interrupt
|
||||||
|
|
||||||
|
;=================================
|
||||||
|
; Finally done with this interrupt
|
||||||
|
;=================================
|
||||||
|
|
||||||
|
quiet_exit:
|
||||||
|
stx DONE_PLAYING
|
||||||
|
jsr clear_ay_both
|
||||||
|
|
||||||
|
ldx #$ff ; also mute the channel
|
||||||
|
stx AY_REGISTERS+7 ; just in case
|
||||||
|
|
||||||
|
|
||||||
|
exit_interrupt:
|
||||||
|
|
||||||
|
pla
|
||||||
|
tay ; restore Y
|
||||||
|
pla
|
||||||
|
tax ; restore X
|
||||||
|
pla ; restore a ; 4
|
||||||
|
|
||||||
|
; on II+/IIe (but not IIc) we need to do this?
|
||||||
|
interrupt_smc:
|
||||||
|
lda $45 ; restore A
|
||||||
|
plp
|
||||||
|
|
||||||
|
rti ; return from interrupt ; 6
|
||||||
|
|
||||||
|
;============
|
||||||
|
; typical
|
||||||
|
; ???? cycles
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#define VGI_HORIZ_TRIANGLE 8
|
#define VGI_HORIZ_TRIANGLE 8
|
||||||
#define VGI_VSTRIPE_RECTANGLE 9
|
#define VGI_VSTRIPE_RECTANGLE 9
|
||||||
#define VGI_LINE 10
|
#define VGI_LINE 10
|
||||||
|
#define VGI_LINE_FAR 11
|
||||||
#define VGI_END 15
|
#define VGI_END 15
|
||||||
|
|
||||||
/* non-encoded pseudo-values */
|
/* non-encoded pseudo-values */
|
||||||
|
@ -55,6 +56,9 @@ int main(int argc, char **argv) {
|
||||||
if (!strncmp(buffer,"LINETO",6)) {
|
if (!strncmp(buffer,"LINETO",6)) {
|
||||||
type=VGI_LINETO;
|
type=VGI_LINETO;
|
||||||
}
|
}
|
||||||
|
else if (!strncmp(buffer,"LINEF",5)) {
|
||||||
|
type=VGI_LINE_FAR;
|
||||||
|
}
|
||||||
else if (!strncmp(buffer,"LINE",4)) {
|
else if (!strncmp(buffer,"LINE",4)) {
|
||||||
type=VGI_LINE;
|
type=VGI_LINE;
|
||||||
}
|
}
|
||||||
|
@ -236,6 +240,28 @@ int main(int argc, char **argv) {
|
||||||
size+=6;
|
size+=6;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VGI_LINE_FAR: /* line */
|
||||||
|
sscanf(buffer,"%*s %i %i %i %i %i",
|
||||||
|
&color1,
|
||||||
|
&x1,&y1,&x2,&y2);
|
||||||
|
printf(".byte $%02X,",(type<<4)|6);
|
||||||
|
if (x1>255) {
|
||||||
|
x1=x1&0xff;
|
||||||
|
color1|=128;
|
||||||
|
}
|
||||||
|
if (x2<256) {
|
||||||
|
fprintf(stderr,"Error! X2 too small %d on line %d\n",x2,line);
|
||||||
|
}
|
||||||
|
x2=x2&0xff;
|
||||||
|
printf("$%02X,",color1);
|
||||||
|
printf("$%02X,",x1);
|
||||||
|
printf("$%02X,",y1);
|
||||||
|
printf("$%02X,",x2);
|
||||||
|
printf("$%02X\n",y2);
|
||||||
|
size+=6;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case VGI_END: /* end */
|
case VGI_END: /* end */
|
||||||
printf(".byte $FF\n");
|
printf(".byte $FF\n");
|
||||||
size+=1;
|
size+=1;
|
||||||
|
|
|
@ -207,6 +207,7 @@ vgi_rts_table:
|
||||||
.word vgi_horizontal_triangle-1 ; 8 = horizontal triangle
|
.word vgi_horizontal_triangle-1 ; 8 = horizontal triangle
|
||||||
.word vgi_vstripe_rectangle-1 ; 9 = vstripe rectangle
|
.word vgi_vstripe_rectangle-1 ; 9 = vstripe rectangle
|
||||||
.word vgi_line-1 ;10 = line
|
.word vgi_line-1 ;10 = line
|
||||||
|
.word vgi_line_far-1 ;11 = line far
|
||||||
.word all_done-1
|
.word all_done-1
|
||||||
.word all_done-1
|
.word all_done-1
|
||||||
.word all_done-1
|
.word all_done-1
|
||||||
|
|
1993
graphics/hgr/vgi/pt3_lib_core.s
Normal file
1993
graphics/hgr/vgi/pt3_lib_core.s
Normal file
File diff suppressed because it is too large
Load Diff
37
graphics/hgr/vgi/pt3_lib_detect_model.s
Normal file
37
graphics/hgr/vgi/pt3_lib_detect_model.s
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
;===========================
|
||||||
|
; Check for Apple IIc
|
||||||
|
;===========================
|
||||||
|
|
||||||
|
|
||||||
|
; ' ' ($20) = Apple II
|
||||||
|
; '+' ($2B) = Apple II+
|
||||||
|
; 'E' ($45) = Apple IIe
|
||||||
|
; 'C' ($43) = Apple IIc
|
||||||
|
; 'G' ($47) = Apple IIgs
|
||||||
|
|
||||||
|
; it does interrupts differently
|
||||||
|
detect_appleii_model:
|
||||||
|
lda #' '
|
||||||
|
sta APPLEII_MODEL
|
||||||
|
|
||||||
|
lda $FBB3 ; IIe and newer is $06
|
||||||
|
cmp #6
|
||||||
|
beq apple_iie_or_newer
|
||||||
|
|
||||||
|
; TODO: check for II+
|
||||||
|
|
||||||
|
jmp done_apple_detect
|
||||||
|
|
||||||
|
apple_iie_or_newer:
|
||||||
|
|
||||||
|
; TODO: check for IIe
|
||||||
|
|
||||||
|
lda $FBC0 ; 0 on a IIc
|
||||||
|
bne done_apple_detect
|
||||||
|
apple_iic:
|
||||||
|
lda #'C'
|
||||||
|
sta APPLEII_MODEL
|
||||||
|
|
||||||
|
done_apple_detect:
|
||||||
|
|
||||||
|
rts
|
575
graphics/hgr/vgi/pt3_lib_init.s
Normal file
575
graphics/hgr/vgi/pt3_lib_init.s
Normal file
|
@ -0,0 +1,575 @@
|
||||||
|
; pt3_lib_init.s
|
||||||
|
|
||||||
|
; Initialize a song
|
||||||
|
|
||||||
|
; this is done before song starts playing so it is not
|
||||||
|
; as performance / timing critical
|
||||||
|
|
||||||
|
;====================================
|
||||||
|
; pt3_init_song
|
||||||
|
;====================================
|
||||||
|
;
|
||||||
|
pt3_init_song:
|
||||||
|
|
||||||
|
lda #$0
|
||||||
|
sta DONE_SONG ; 3
|
||||||
|
ldx #(end_vars-begin_vars)
|
||||||
|
zero_song_structs_loop:
|
||||||
|
dex
|
||||||
|
sta note_a,X
|
||||||
|
bne zero_song_structs_loop
|
||||||
|
|
||||||
|
sta pt3_noise_period_smc+1 ; 4
|
||||||
|
sta pt3_noise_add_smc+1 ; 4
|
||||||
|
|
||||||
|
sta pt3_envelope_period_l_smc+1 ; 4
|
||||||
|
sta pt3_envelope_period_h_smc+1 ; 4
|
||||||
|
sta pt3_envelope_slide_l_smc+1 ; 4
|
||||||
|
sta pt3_envelope_slide_h_smc+1 ; 4
|
||||||
|
sta pt3_envelope_slide_add_l_smc+1 ; 4
|
||||||
|
sta pt3_envelope_slide_add_h_smc+1 ; 4
|
||||||
|
sta pt3_envelope_add_smc+1 ; 4
|
||||||
|
sta pt3_envelope_type_smc+1 ; 4
|
||||||
|
sta pt3_envelope_type_old_smc+1 ; 4
|
||||||
|
sta pt3_envelope_delay_smc+1 ; 4
|
||||||
|
sta pt3_envelope_delay_orig_smc+1 ; 4
|
||||||
|
|
||||||
|
sta PT3_MIXER_VAL ; 3
|
||||||
|
|
||||||
|
sta current_pattern_smc+1 ; 4
|
||||||
|
sta current_line_smc+1 ; 4
|
||||||
|
sta current_subframe_smc+1 ; 4
|
||||||
|
|
||||||
|
lda #$f ; 2
|
||||||
|
sta note_a+NOTE_VOLUME ; 4
|
||||||
|
sta note_b+NOTE_VOLUME ; 4
|
||||||
|
sta note_c+NOTE_VOLUME ; 4
|
||||||
|
|
||||||
|
; default ornament/sample in A
|
||||||
|
; X is zero coming in here
|
||||||
|
;ldx #(NOTE_STRUCT_SIZE*0) ; 2
|
||||||
|
jsr load_ornament0_sample1 ; 6+93
|
||||||
|
|
||||||
|
; default ornament/sample in B
|
||||||
|
ldx #(NOTE_STRUCT_SIZE*1) ; 2
|
||||||
|
jsr load_ornament0_sample1 ; 6+93
|
||||||
|
|
||||||
|
; default ornament/sample in C
|
||||||
|
ldx #(NOTE_STRUCT_SIZE*2) ; 2
|
||||||
|
jsr load_ornament0_sample1 ; 6+93
|
||||||
|
|
||||||
|
;=======================
|
||||||
|
; load default speed
|
||||||
|
|
||||||
|
lda PT3_LOC+PT3_SPEED ; 4
|
||||||
|
sta pt3_speed_smc+1 ; 4
|
||||||
|
|
||||||
|
;=======================
|
||||||
|
; load loop
|
||||||
|
|
||||||
|
lda PT3_LOC+PT3_LOOP ; 4
|
||||||
|
sta pt3_loop_smc+1 ; 4
|
||||||
|
|
||||||
|
|
||||||
|
;========================
|
||||||
|
;========================
|
||||||
|
; set up note/freq table
|
||||||
|
; this saves some space and makes things marginally faster longrun
|
||||||
|
;========================
|
||||||
|
;========================
|
||||||
|
; note (heh) that there are separate tables if version 3.3
|
||||||
|
; but we are going to assume we are only going to be playing
|
||||||
|
; newer 3.4+ version files so only need the newer tables
|
||||||
|
|
||||||
|
ldx PT3_LOC+PT3_HEADER_FREQUENCY ; 4
|
||||||
|
beq use_freq_table_0
|
||||||
|
dex
|
||||||
|
beq use_freq_table_1
|
||||||
|
dex
|
||||||
|
beq use_freq_table_2
|
||||||
|
; fallthrough (freq table 3)
|
||||||
|
|
||||||
|
use_freq_table_3:
|
||||||
|
;=================================================
|
||||||
|
; Create Table #3, v4+, "PT3NoteTable_REAL_34_35"
|
||||||
|
;=================================================
|
||||||
|
|
||||||
|
ldy #11 ; !2
|
||||||
|
freq_table_3_copy_loop:
|
||||||
|
; note, high lookup almost same as 2v4, just need to adjust one value
|
||||||
|
|
||||||
|
lda base2_v4_high,Y ; !3
|
||||||
|
sta NoteTable_high,Y ; !3
|
||||||
|
lda base3_low,Y ; !3
|
||||||
|
sta NoteTable_low,Y ; !3
|
||||||
|
dey ; !1
|
||||||
|
bpl freq_table_3_copy_loop ; !2
|
||||||
|
|
||||||
|
dec NoteTable_high ; adjust to right value
|
||||||
|
|
||||||
|
jsr NoteTablePropogate ; !3
|
||||||
|
|
||||||
|
lda #<table3_v4_adjust
|
||||||
|
sta note_table_adjust_smc+1
|
||||||
|
lda #>table3_v4_adjust
|
||||||
|
sta note_table_adjust_smc+2
|
||||||
|
|
||||||
|
jsr NoteTableAdjust
|
||||||
|
|
||||||
|
jmp done_set_freq_table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use_freq_table_2:
|
||||||
|
;=================================================
|
||||||
|
; Create Table #2, v4+, "PT3NoteTable_ASM_34_35"
|
||||||
|
;=================================================
|
||||||
|
|
||||||
|
ldy #11
|
||||||
|
freq_table_2_copy_loop:
|
||||||
|
lda base2_v4_high,Y
|
||||||
|
sta NoteTable_high,Y
|
||||||
|
lda base2_v4_low,Y
|
||||||
|
sta NoteTable_low,Y
|
||||||
|
dey
|
||||||
|
bpl freq_table_2_copy_loop
|
||||||
|
|
||||||
|
jsr NoteTablePropogate ; !3
|
||||||
|
|
||||||
|
lda #<table2_v4_adjust
|
||||||
|
sta note_table_adjust_smc+1
|
||||||
|
lda #>table2_v4_adjust
|
||||||
|
sta note_table_adjust_smc+2
|
||||||
|
|
||||||
|
jsr NoteTableAdjust
|
||||||
|
|
||||||
|
jmp done_set_freq_table
|
||||||
|
|
||||||
|
use_freq_table_1:
|
||||||
|
;=================================================
|
||||||
|
; Create Table #1, "PT3NoteTable_ST"
|
||||||
|
;=================================================
|
||||||
|
|
||||||
|
ldy #11
|
||||||
|
freq_table_1_copy_loop:
|
||||||
|
lda base1_high,Y
|
||||||
|
sta NoteTable_high,Y
|
||||||
|
lda base1_low,Y
|
||||||
|
sta NoteTable_low,Y
|
||||||
|
dey
|
||||||
|
bpl freq_table_1_copy_loop
|
||||||
|
|
||||||
|
jsr NoteTablePropogate ; !3
|
||||||
|
|
||||||
|
; last adjustments
|
||||||
|
lda #$FD ; Tone[23]=$3FD
|
||||||
|
sta NoteTable_low+23
|
||||||
|
dec NoteTable_low+46 ; Tone[46]-=1;
|
||||||
|
|
||||||
|
|
||||||
|
jmp done_set_freq_table
|
||||||
|
|
||||||
|
|
||||||
|
use_freq_table_0:
|
||||||
|
;=================================================
|
||||||
|
; Create Table #0, "PT3NoteTable_PT_34_35"
|
||||||
|
;=================================================
|
||||||
|
|
||||||
|
ldy #11
|
||||||
|
freq_table_0_copy_loop:
|
||||||
|
lda base0_v4_high,Y
|
||||||
|
sta NoteTable_high,Y
|
||||||
|
lda base0_v4_low,Y
|
||||||
|
sta NoteTable_low,Y
|
||||||
|
dey
|
||||||
|
bpl freq_table_0_copy_loop
|
||||||
|
|
||||||
|
jsr NoteTablePropogate ; !3
|
||||||
|
|
||||||
|
lda #<table0_v4_adjust
|
||||||
|
sta note_table_adjust_smc+1
|
||||||
|
lda #>table0_v4_adjust
|
||||||
|
sta note_table_adjust_smc+2
|
||||||
|
|
||||||
|
jsr NoteTableAdjust
|
||||||
|
|
||||||
|
|
||||||
|
done_set_freq_table:
|
||||||
|
|
||||||
|
|
||||||
|
;======================
|
||||||
|
; calculate version
|
||||||
|
ldx #6 ; 2
|
||||||
|
lda PT3_LOC+PT3_VERSION ; 4
|
||||||
|
sec ; 2
|
||||||
|
sbc #'0' ; 2
|
||||||
|
cmp #9 ; 2
|
||||||
|
bcs not_ascii_number ; bge ; 2/3
|
||||||
|
tax ; 2
|
||||||
|
|
||||||
|
not_ascii_number:
|
||||||
|
|
||||||
|
; adjust version<6 SMC code in the slide code
|
||||||
|
|
||||||
|
; FIXME: I am sure there's a more clever way to do this
|
||||||
|
|
||||||
|
lda #$2C ; BIT ; 2
|
||||||
|
cpx #$6 ; 2
|
||||||
|
bcs version_greater_than_or_equal_6 ; bgt ; 3
|
||||||
|
; less than 6, jump
|
||||||
|
; also carry is known to be clear
|
||||||
|
adc #$20 ; BIT->JMP 2C->4C ; 2
|
||||||
|
version_greater_than_or_equal_6:
|
||||||
|
sta version_smc ; 4
|
||||||
|
|
||||||
|
pick_volume_table:
|
||||||
|
|
||||||
|
;=======================
|
||||||
|
; Pick which volume number, based on version
|
||||||
|
|
||||||
|
; if (PlParams.PT3.PT3_Version <= 4)
|
||||||
|
|
||||||
|
cpx #5 ; 2
|
||||||
|
|
||||||
|
; carry clear = 3.3/3.4 table
|
||||||
|
; carry set = 3.5 table
|
||||||
|
|
||||||
|
;==========================
|
||||||
|
; VolTableCreator
|
||||||
|
;==========================
|
||||||
|
; Creates the appropriate volume table
|
||||||
|
; based on z80 code by Ivan Roshin ZXAYHOBETA/VTII10bG.asm
|
||||||
|
;
|
||||||
|
|
||||||
|
; Called with carry==0 for 3.3/3.4 table
|
||||||
|
; Called with carry==1 for 3.5 table
|
||||||
|
|
||||||
|
; 177f-1932 = 435 bytes, not that much better than 512 of lookup
|
||||||
|
|
||||||
|
|
||||||
|
VolTableCreator:
|
||||||
|
|
||||||
|
; Init initial variables
|
||||||
|
lda #$0
|
||||||
|
sta z80_d_smc+1
|
||||||
|
ldy #$11
|
||||||
|
|
||||||
|
; Set up self modify
|
||||||
|
|
||||||
|
ldx #$2A ; ROL for self-modify
|
||||||
|
bcs vol_type_35
|
||||||
|
|
||||||
|
vol_type_33:
|
||||||
|
|
||||||
|
; For older table, we set initial conditions a bit
|
||||||
|
; different
|
||||||
|
|
||||||
|
dey
|
||||||
|
tya
|
||||||
|
|
||||||
|
ldx #$ea ; NOP for self modify
|
||||||
|
|
||||||
|
vol_type_35:
|
||||||
|
sty z80_l_smc+1 ; l=16 or 17
|
||||||
|
sta z80_e_smc+1 ; e=16 or 0
|
||||||
|
stx vol_smc ; set the self-modify code
|
||||||
|
|
||||||
|
ldy #16 ; skip first row, all zeros
|
||||||
|
ldx #16 ; c=16
|
||||||
|
vol_outer:
|
||||||
|
clc ; add HL,DE
|
||||||
|
z80_l_smc:
|
||||||
|
lda #$d1
|
||||||
|
z80_e_smc:
|
||||||
|
adc #$d1
|
||||||
|
sta z80_e_smc+1
|
||||||
|
lda #0
|
||||||
|
z80_d_smc:
|
||||||
|
adc #$d1
|
||||||
|
sta z80_d_smc+1 ; carry is important
|
||||||
|
|
||||||
|
; sbc hl,hl
|
||||||
|
lda #0
|
||||||
|
adc #$ff
|
||||||
|
eor #$ff
|
||||||
|
|
||||||
|
vol_write:
|
||||||
|
sta z80_h_smc+1
|
||||||
|
pha
|
||||||
|
|
||||||
|
vol_inner:
|
||||||
|
pla
|
||||||
|
pha
|
||||||
|
|
||||||
|
vol_smc:
|
||||||
|
nop ; nop or ROL depending
|
||||||
|
|
||||||
|
z80_h_smc:
|
||||||
|
lda #$d1
|
||||||
|
|
||||||
|
adc #$0 ; a=a+carry;
|
||||||
|
|
||||||
|
sta VolumeTable,Y
|
||||||
|
iny
|
||||||
|
|
||||||
|
pla ; add HL,DE
|
||||||
|
adc z80_e_smc+1
|
||||||
|
pha
|
||||||
|
lda z80_h_smc+1
|
||||||
|
adc z80_d_smc+1
|
||||||
|
sta z80_h_smc+1
|
||||||
|
|
||||||
|
inx ; inc C
|
||||||
|
txa ; a=c
|
||||||
|
and #$f
|
||||||
|
bne vol_inner
|
||||||
|
|
||||||
|
|
||||||
|
pla
|
||||||
|
|
||||||
|
lda z80_e_smc+1 ; a=e
|
||||||
|
cmp #$77
|
||||||
|
bne vol_m3
|
||||||
|
|
||||||
|
inc z80_e_smc+1
|
||||||
|
|
||||||
|
vol_m3:
|
||||||
|
txa ; a=c
|
||||||
|
bne vol_outer
|
||||||
|
|
||||||
|
vol_done:
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;=========================================
|
||||||
|
; copy note table seed to proper location
|
||||||
|
;=========================================
|
||||||
|
|
||||||
|
; faster inlined
|
||||||
|
|
||||||
|
;NoteTableCopy:
|
||||||
|
|
||||||
|
; ldy #11 ; !2
|
||||||
|
;note_table_copy_loop:
|
||||||
|
;ntc_smc1:
|
||||||
|
; lda base1_high,Y ; !3
|
||||||
|
; sta NoteTable_high,Y ; !3
|
||||||
|
;ntc_smc2:
|
||||||
|
; lda base1_low,Y ; !3
|
||||||
|
; sta NoteTable_low,Y ; !3
|
||||||
|
; dey ; !1
|
||||||
|
; bpl note_table_copy_loop ; !2
|
||||||
|
; rts ; !1
|
||||||
|
|
||||||
|
|
||||||
|
;==========================================
|
||||||
|
; propogate the freq down, dividing by two
|
||||||
|
;==========================================
|
||||||
|
NoteTablePropogate:
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
note_table_propogate_loop:
|
||||||
|
clc
|
||||||
|
lda NoteTable_high,Y
|
||||||
|
ror
|
||||||
|
sta NoteTable_high+12,Y
|
||||||
|
|
||||||
|
lda NoteTable_low,Y
|
||||||
|
ror
|
||||||
|
sta NoteTable_low+12,Y
|
||||||
|
|
||||||
|
iny
|
||||||
|
cpy #84
|
||||||
|
bne note_table_propogate_loop
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;================================================
|
||||||
|
; propogation isn't enough, various values
|
||||||
|
; are often off by one, so adjust using a bitmask
|
||||||
|
;================================================
|
||||||
|
NoteTableAdjust:
|
||||||
|
|
||||||
|
ldx #0
|
||||||
|
note_table_adjust_outer:
|
||||||
|
|
||||||
|
note_table_adjust_smc:
|
||||||
|
lda table0_v4_adjust,X
|
||||||
|
sta PT3_TEMP
|
||||||
|
|
||||||
|
; reset smc
|
||||||
|
lda #<NoteTable_low
|
||||||
|
sta ntl_smc+1
|
||||||
|
lda #>NoteTable_low
|
||||||
|
sta ntl_smc+2
|
||||||
|
|
||||||
|
|
||||||
|
ldy #7
|
||||||
|
note_table_adjust_inner:
|
||||||
|
ror PT3_TEMP
|
||||||
|
bcc note_table_skip_adjust
|
||||||
|
|
||||||
|
ntl_smc:
|
||||||
|
inc NoteTable_low,X
|
||||||
|
|
||||||
|
note_table_skip_adjust:
|
||||||
|
clc
|
||||||
|
lda #12
|
||||||
|
adc ntl_smc+1
|
||||||
|
sta ntl_smc+1
|
||||||
|
lda #0
|
||||||
|
adc ntl_smc+2 ; unnecessary if aligned
|
||||||
|
sta ntl_smc+2
|
||||||
|
|
||||||
|
skip_adjust_done:
|
||||||
|
dey
|
||||||
|
bpl note_table_adjust_inner
|
||||||
|
|
||||||
|
inx
|
||||||
|
cpx #12
|
||||||
|
bne note_table_adjust_outer
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;base0_v3_high:
|
||||||
|
;.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||||
|
;base0_v3_low:
|
||||||
|
;.byte $21,$73,$CE,$33,$A0,$16,$93,$18,$A4,$36,$CE,$6D
|
||||||
|
|
||||||
|
; note: same as base0_v3_high
|
||||||
|
base0_v4_high:
|
||||||
|
.byte $0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06,$06
|
||||||
|
base0_v4_low:
|
||||||
|
.byte $22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF,$6D
|
||||||
|
|
||||||
|
base1_high:
|
||||||
|
.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07
|
||||||
|
base1_low:
|
||||||
|
.byte $F8,$10,$60,$80,$D8,$28,$88,$F0,$60,$E0,$58,$E0
|
||||||
|
|
||||||
|
;base2_v3_high:
|
||||||
|
;.byte $0D,$0C,$0B,$0B,$0A,$09,$09,$08,$08,$07,$07,$07
|
||||||
|
;base2_v3_low:
|
||||||
|
;.byte $3E,$80,$CC,$22,$82,$EC,$5C,$D6,$58,$E0,$6E,$04
|
||||||
|
|
||||||
|
; note almost same as above
|
||||||
|
base2_v4_high:
|
||||||
|
.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||||
|
base2_v4_low:
|
||||||
|
.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8,$3B,$C5,$55,$EC
|
||||||
|
|
||||||
|
; note almost same as above
|
||||||
|
;base3_high:
|
||||||
|
;.byte $0C,$0C,$0B,$0A,$0A,$09,$09,$08,$08,$07,$07,$06
|
||||||
|
base3_low:
|
||||||
|
.byte $DA,$22,$73,$CF,$33,$A1,$17,$94,$19,$A4,$37,$CF
|
||||||
|
|
||||||
|
|
||||||
|
; Adjustment factors
|
||||||
|
table0_v4_adjust:
|
||||||
|
.byte $40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c,$5a
|
||||||
|
|
||||||
|
table2_v4_adjust:
|
||||||
|
.byte $20,$a8,$40,$f8,$bc,$90,$78,$70,$74,$08,$2a,$50
|
||||||
|
|
||||||
|
table3_v4_adjust:
|
||||||
|
.byte $B4,$40,$e6,$9c,$66,$40,$2c,$20,$30,$48,$6c,$1c
|
||||||
|
|
||||||
|
|
||||||
|
; Table #1 of Pro Tracker 3.3x - 3.5x
|
||||||
|
;PT3NoteTable_ST_high:
|
||||||
|
;.byte $0E,$0E,$0D,$0C,$0B,$0B,$0A,$09
|
||||||
|
;.byte $09,$08,$08,$07,$07,$07,$06,$06
|
||||||
|
;.byte $05,$05,$05,$04,$04,$04,$04,$03
|
||||||
|
;.byte $03,$03,$03,$03,$02,$02,$02,$02
|
||||||
|
;.byte $02,$02,$02,$01,$01,$01,$01,$01
|
||||||
|
;.byte $01,$01,$01,$01,$01,$01,$01,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
|
||||||
|
;PT3NoteTable_ST_low:
|
||||||
|
;.byte $F8,$10,$60,$80,$D8,$28,$88,$F0
|
||||||
|
;.byte $60,$E0,$58,$E0,$7C,$08,$B0,$40
|
||||||
|
;.byte $EC,$94,$44,$F8,$B0,$70,$2C,$FD
|
||||||
|
;.byte $BE,$84,$58,$20,$F6,$CA,$A2,$7C
|
||||||
|
;.byte $58,$38,$16,$F8,$DF,$C2,$AC,$90
|
||||||
|
;.byte $7B,$65,$51,$3E,$2C,$1C,$0A,$FC
|
||||||
|
;.byte $EF,$E1,$D6,$C8,$BD,$B2,$A8,$9F
|
||||||
|
;.byte $96,$8E,$85,$7E,$77,$70,$6B,$64
|
||||||
|
;.byte $5E,$59,$54,$4F,$4B,$47,$42,$3F
|
||||||
|
;.byte $3B,$38,$35,$32,$2F,$2C,$2A,$27
|
||||||
|
;.byte $25,$23,$21,$1F,$1D,$1C,$1A,$19
|
||||||
|
;.byte $17,$16,$15,$13,$12,$11,$10,$0F
|
||||||
|
|
||||||
|
|
||||||
|
; Table #2 of Pro Tracker 3.4x - 3.5x
|
||||||
|
;PT3NoteTable_ASM_34_35_high:
|
||||||
|
;.byte $0D,$0C,$0B,$0A,$0A,$09,$09,$08
|
||||||
|
;.byte $08,$07,$07,$06,$06,$06,$05,$05
|
||||||
|
;.byte $05,$04,$04,$04,$04,$03,$03,$03
|
||||||
|
;.byte $03,$03,$02,$02,$02,$02,$02,$02
|
||||||
|
;.byte $02,$01,$01,$01,$01,$01,$01,$01
|
||||||
|
;.byte $01,$01,$01,$01,$01,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
;.byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
|
||||||
|
;PT3NoteTable_ASM_34_35_low:
|
||||||
|
;.byte $10,$55,$A4,$FC,$5F,$CA,$3D,$B8
|
||||||
|
;.byte $3B,$C5,$55,$EC,$88,$2A,$D2,$7E
|
||||||
|
;.byte $2F,$E5,$9E,$5C,$1D,$E2,$AB,$76
|
||||||
|
;.byte $44,$15,$E9,$BF,$98,$72,$4F,$2E
|
||||||
|
;.byte $0F,$F1,$D5,$BB,$A2,$8B,$74,$60
|
||||||
|
;.byte $4C,$39,$28,$17,$07,$F9,$EB,$DD
|
||||||
|
;.byte $D1,$C5,$BA,$B0,$A6,$9D,$94,$8C
|
||||||
|
;.byte $84,$7C,$75,$6F,$69,$63,$5D,$58
|
||||||
|
;.byte $53,$4E,$4A,$46,$42,$3E,$3B,$37
|
||||||
|
;.byte $34,$31,$2F,$2C,$29,$27,$25,$23
|
||||||
|
;.byte $21,$1F,$1D,$1C,$1A,$19,$17,$16
|
||||||
|
;.byte $15,$14,$12,$11,$10,$0F,$0E,$0D
|
||||||
|
|
||||||
|
|
||||||
|
;PT3VolumeTable_33_34:
|
||||||
|
;.byte $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
|
||||||
|
;.byte $0,$0,$0,$0,$0,$0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1
|
||||||
|
;.byte $0,$0,$0,$0,$0,$0,$1,$1,$1,$1,$1,$2,$2,$2,$2,$2
|
||||||
|
;.byte $0,$0,$0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3
|
||||||
|
;.byte $0,$0,$0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4
|
||||||
|
;.byte $0,$0,$0,$1,$1,$1,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||||
|
;.byte $0,$0,$0,$1,$1,$2,$2,$3,$3,$3,$4,$4,$5,$5,$6,$6
|
||||||
|
;.byte $0,$0,$1,$1,$2,$2,$3,$3,$4,$4,$5,$5,$6,$6,$7,$7
|
||||||
|
;.byte $0,$0,$1,$1,$2,$2,$3,$3,$4,$5,$5,$6,$6,$7,$7,$8
|
||||||
|
;.byte $0,$0,$1,$1,$2,$3,$3,$4,$5,$5,$6,$6,$7,$8,$8,$9
|
||||||
|
;.byte $0,$0,$1,$2,$2,$3,$4,$4,$5,$6,$6,$7,$8,$8,$9,$A
|
||||||
|
;.byte $0,$0,$1,$2,$3,$3,$4,$5,$6,$6,$7,$8,$9,$9,$A,$B
|
||||||
|
;.byte $0,$0,$1,$2,$3,$4,$4,$5,$6,$7,$8,$8,$9,$A,$B,$C
|
||||||
|
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$7,$7,$8,$9,$A,$B,$C,$D
|
||||||
|
;.byte $0,$0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E
|
||||||
|
;.byte $0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E,$F
|
||||||
|
|
||||||
|
;PT3VolumeTable_35:
|
||||||
|
;.byte $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
|
||||||
|
;.byte $0,$0,$0,$0,$0,$0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1
|
||||||
|
;.byte $0,$0,$0,$0,$1,$1,$1,$1,$1,$1,$1,$1,$2,$2,$2,$2
|
||||||
|
;.byte $0,$0,$0,$1,$1,$1,$1,$1,$2,$2,$2,$2,$2,$3,$3,$3
|
||||||
|
;.byte $0,$0,$1,$1,$1,$1,$2,$2,$2,$2,$3,$3,$3,$3,$4,$4
|
||||||
|
;.byte $0,$0,$1,$1,$1,$2,$2,$2,$3,$3,$3,$4,$4,$4,$5,$5
|
||||||
|
;.byte $0,$0,$1,$1,$2,$2,$2,$3,$3,$4,$4,$4,$5,$5,$6,$6
|
||||||
|
;.byte $0,$0,$1,$1,$2,$2,$3,$3,$4,$4,$5,$5,$6,$6,$7,$7
|
||||||
|
;.byte $0,$1,$1,$2,$2,$3,$3,$4,$4,$5,$5,$6,$6,$7,$7,$8
|
||||||
|
;.byte $0,$1,$1,$2,$2,$3,$4,$4,$5,$5,$6,$7,$7,$8,$8,$9
|
||||||
|
;.byte $0,$1,$1,$2,$3,$3,$4,$5,$5,$6,$7,$7,$8,$9,$9,$A
|
||||||
|
;.byte $0,$1,$1,$2,$3,$4,$4,$5,$6,$7,$7,$8,$9,$A,$A,$B
|
||||||
|
;.byte $0,$1,$2,$2,$3,$4,$5,$6,$6,$7,$8,$9,$A,$A,$B,$C
|
||||||
|
;.byte $0,$1,$2,$3,$3,$4,$5,$6,$7,$8,$9,$A,$A,$B,$C,$D
|
||||||
|
;.byte $0,$1,$2,$3,$4,$5,$6,$7,$7,$8,$9,$A,$B,$C,$D,$E
|
||||||
|
;.byte $0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E,$F
|
117
graphics/hgr/vgi/pt3_lib_irq_handler.s
Normal file
117
graphics/hgr/vgi/pt3_lib_irq_handler.s
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
|
||||||
|
|
||||||
|
pt3_irq_handler:
|
||||||
|
|
||||||
|
pt3_irq_smc1:
|
||||||
|
bit MOCK_6522_T1CL ; clear 6522 interrupt by reading T1C-L ; 4
|
||||||
|
|
||||||
|
lda DONE_PLAYING ; 3
|
||||||
|
beq pt3_play_music ; if song done, don't play music ; 3/2nt
|
||||||
|
jmp done_pt3_irq_handler ; 3
|
||||||
|
;============
|
||||||
|
; 13
|
||||||
|
|
||||||
|
pt3_play_music:
|
||||||
|
|
||||||
|
; decode a frame of music
|
||||||
|
|
||||||
|
jsr pt3_make_frame
|
||||||
|
|
||||||
|
; handle song over condition
|
||||||
|
lda DONE_SONG
|
||||||
|
beq mb_write_frame ; if not done, continue
|
||||||
|
|
||||||
|
lda LOOP ; see if looping
|
||||||
|
beq move_to_next
|
||||||
|
|
||||||
|
pt3_loop_smc:
|
||||||
|
lda #$d1 ; looping, move to loop location
|
||||||
|
; non-zero to avoid the temptation
|
||||||
|
; to merge with following lda #$0
|
||||||
|
sta current_pattern_smc+1
|
||||||
|
lda #$0
|
||||||
|
sta current_line_smc+1
|
||||||
|
sta current_subframe_smc+1
|
||||||
|
sta DONE_SONG ; undo the next song
|
||||||
|
|
||||||
|
; beq done_pt3_irq_handler ; branch always
|
||||||
|
beq pt3_play_music ; branch always
|
||||||
|
|
||||||
|
move_to_next:
|
||||||
|
; same as "press right"
|
||||||
|
ldx #$20
|
||||||
|
jmp quiet_exit
|
||||||
|
|
||||||
|
;======================================
|
||||||
|
; Write frames to Mockingboard
|
||||||
|
;======================================
|
||||||
|
; for speed could merge this into
|
||||||
|
; the decode code
|
||||||
|
|
||||||
|
mb_write_frame:
|
||||||
|
|
||||||
|
|
||||||
|
tax ; set up reg count ; 2
|
||||||
|
;============
|
||||||
|
; 2
|
||||||
|
|
||||||
|
;==================================
|
||||||
|
; loop through the 14 registers
|
||||||
|
; reading the value, then write out
|
||||||
|
;==================================
|
||||||
|
|
||||||
|
mb_write_loop:
|
||||||
|
lda AY_REGISTERS,X ; load register value ; 4
|
||||||
|
|
||||||
|
; special case R13. If it is 0xff, then don't update
|
||||||
|
; otherwise might spuriously reset the envelope settings
|
||||||
|
|
||||||
|
cpx #13 ; 2
|
||||||
|
bne mb_not_13 ; 3/2nt
|
||||||
|
cmp #$ff ; 2
|
||||||
|
beq mb_skip_13 ; 3/2nt
|
||||||
|
;============
|
||||||
|
; typ 5
|
||||||
|
mb_not_13:
|
||||||
|
|
||||||
|
|
||||||
|
; address
|
||||||
|
pt3_irq_smc2:
|
||||||
|
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
|
||||||
|
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
|
||||||
|
ldy #MOCK_AY_LATCH_ADDR ; latch_address for PB1 ; 2
|
||||||
|
pt3_irq_smc3:
|
||||||
|
sty MOCK_6522_ORB1 ; latch_address on PB1 ; 4
|
||||||
|
sty MOCK_6522_ORB2 ; latch_address on PB2 ; 4
|
||||||
|
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
|
||||||
|
pt3_irq_smc4:
|
||||||
|
sty MOCK_6522_ORB1 ; 4
|
||||||
|
sty MOCK_6522_ORB2 ; 4
|
||||||
|
|
||||||
|
; value
|
||||||
|
pt3_irq_smc5:
|
||||||
|
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
|
||||||
|
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
|
||||||
|
lda #MOCK_AY_WRITE ; ; 2
|
||||||
|
pt3_irq_smc6:
|
||||||
|
sta MOCK_6522_ORB1 ; write on PB1 ; 4
|
||||||
|
sty MOCK_6522_ORB1 ; 4
|
||||||
|
pt3_irq_smc7:
|
||||||
|
sta MOCK_6522_ORB2 ; write on PB2 ; 4
|
||||||
|
sty MOCK_6522_ORB2 ; 4
|
||||||
|
;===========
|
||||||
|
; 56
|
||||||
|
mb_no_write:
|
||||||
|
inx ; point to next register ; 2
|
||||||
|
cpx #14 ; if 14 we're done ; 2
|
||||||
|
bmi mb_write_loop ; otherwise, loop ; 3/2nt
|
||||||
|
;============
|
||||||
|
; 7
|
||||||
|
mb_skip_13:
|
||||||
|
|
||||||
|
|
||||||
|
;=================================
|
||||||
|
; Finally done with this interrupt
|
||||||
|
;=================================
|
||||||
|
|
||||||
|
done_pt3_irq_handler:
|
334
graphics/hgr/vgi/pt3_lib_mockingboard_detect.s
Normal file
334
graphics/hgr/vgi/pt3_lib_mockingboard_detect.s
Normal file
|
@ -0,0 +1,334 @@
|
||||||
|
;===================================================================
|
||||||
|
; code to detect mockingboard
|
||||||
|
;===================================================================
|
||||||
|
; this isn't always easy
|
||||||
|
; my inclination is to just assume slot #4 but that isn't always realistic
|
||||||
|
|
||||||
|
; code below based on "hw.mockingboard.a" from "Total Replay"
|
||||||
|
|
||||||
|
;license:MIT
|
||||||
|
; By Andrew Roughan
|
||||||
|
; in the style of 4am for Total Replay
|
||||||
|
;
|
||||||
|
; Mockingboard support functions
|
||||||
|
;
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; HasMockingboard
|
||||||
|
; detect Mockingboard card by searching for 6522 timers across all slots
|
||||||
|
; access 6522 timers with deterministic cycle counts
|
||||||
|
;
|
||||||
|
; based on prior art in Mockingboard Developers Toolkit
|
||||||
|
; with optimisation from deater/french touch
|
||||||
|
; also takes into account FastChip //e clock difference
|
||||||
|
;
|
||||||
|
; in: none
|
||||||
|
; accelerators should be off
|
||||||
|
; out: C set if Mockingboard found in any slot
|
||||||
|
; if card was found, X = #$Cn where n is the slot number of the card
|
||||||
|
; C clear if no Mockingboard found
|
||||||
|
; other flags clobbered
|
||||||
|
; zp $65-$67 clobbered
|
||||||
|
; A/Y clobbered
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
mockingboard_detect:
|
||||||
|
|
||||||
|
; activate IIc mockingboard?
|
||||||
|
; this might only be necessary to allow detection
|
||||||
|
; I get the impression the Mockingboard 4c activates
|
||||||
|
; when you access any of the 6522 ports in Slot 4
|
||||||
|
|
||||||
|
.ifdef PT3_ENABLE_APPLE_IIC
|
||||||
|
lda APPLEII_MODEL
|
||||||
|
cmp #'C'
|
||||||
|
bne not_iic
|
||||||
|
|
||||||
|
lda #$ff
|
||||||
|
|
||||||
|
; don't bother patching these, IIc mockingboard always slot 4?
|
||||||
|
|
||||||
|
sta MOCK_6522_DDRA1
|
||||||
|
sta MOCK_6522_T1CL
|
||||||
|
.endif
|
||||||
|
|
||||||
|
not_iic:
|
||||||
|
lda #$00
|
||||||
|
sta MB_ADDR_L
|
||||||
|
ldx #$C7 ; start at slot #7
|
||||||
|
mb_slot_loop:
|
||||||
|
stx MB_ADDR_H
|
||||||
|
ldy #$04 ; 6522 #1 $Cx04
|
||||||
|
jsr mb_timer_check
|
||||||
|
bne mb_next_slot
|
||||||
|
ldy #$84 ; 6522 #2 $Cx84
|
||||||
|
jsr mb_timer_check
|
||||||
|
bne mb_next_slot
|
||||||
|
mb_found:
|
||||||
|
sec ; found
|
||||||
|
rts
|
||||||
|
|
||||||
|
mb_next_slot:
|
||||||
|
dex
|
||||||
|
cpx #$C0
|
||||||
|
bne mb_slot_loop
|
||||||
|
|
||||||
|
clc ; not found
|
||||||
|
rts
|
||||||
|
|
||||||
|
mb_timer_check:
|
||||||
|
lda (MB_ADDR_L),Y ; read 6522 timer low byte
|
||||||
|
sta MB_VALUE
|
||||||
|
lda (MB_ADDR_L),Y ; second time
|
||||||
|
sec
|
||||||
|
sbc MB_VALUE
|
||||||
|
cmp #$F8 ; looking for (-)8 cycles between reads
|
||||||
|
beq mb_timer_check_done
|
||||||
|
cmp #$F7 ; FastChip //e clock is different
|
||||||
|
mb_timer_check_done:
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;===================================================================
|
||||||
|
; code to patch mockingboard if not in slot#4
|
||||||
|
;===================================================================
|
||||||
|
; this is the brute force version, we have to patch 39 locations
|
||||||
|
; see further below if you want to try a smaller, more dangerous, patch
|
||||||
|
|
||||||
|
.if 0
|
||||||
|
mockingboard_patch:
|
||||||
|
|
||||||
|
lda MB_ADDR_H
|
||||||
|
|
||||||
|
sta pt3_irq_smc1+2 ; 1
|
||||||
|
|
||||||
|
sta pt3_irq_smc2+2 ; 2
|
||||||
|
sta pt3_irq_smc2+5 ; 3
|
||||||
|
|
||||||
|
sta pt3_irq_smc3+2 ; 4
|
||||||
|
sta pt3_irq_smc3+5 ; 5
|
||||||
|
|
||||||
|
sta pt3_irq_smc4+2 ; 6
|
||||||
|
sta pt3_irq_smc4+5 ; 7
|
||||||
|
|
||||||
|
sta pt3_irq_smc5+2 ; 8
|
||||||
|
sta pt3_irq_smc5+5 ; 9
|
||||||
|
|
||||||
|
sta pt3_irq_smc6+2 ; 10
|
||||||
|
sta pt3_irq_smc6+5 ; 11
|
||||||
|
|
||||||
|
sta pt3_irq_smc7+2 ; 12
|
||||||
|
sta pt3_irq_smc7+5 ; 13
|
||||||
|
|
||||||
|
sta mock_init_smc1+2 ; 14
|
||||||
|
sta mock_init_smc1+5 ; 15
|
||||||
|
|
||||||
|
sta mock_init_smc2+2 ; 16
|
||||||
|
sta mock_init_smc2+5 ; 17
|
||||||
|
|
||||||
|
sta reset_ay_smc1+2 ; 18
|
||||||
|
sta reset_ay_smc2+2 ; 19
|
||||||
|
sta reset_ay_smc3+2 ; 20
|
||||||
|
sta reset_ay_smc4+2 ; 21
|
||||||
|
|
||||||
|
sta write_ay_smc1+2 ; 22
|
||||||
|
sta write_ay_smc1+5 ; 23
|
||||||
|
|
||||||
|
sta write_ay_smc2+2 ; 24
|
||||||
|
sta write_ay_smc2+5 ; 25
|
||||||
|
|
||||||
|
sta write_ay_smc3+2 ; 26
|
||||||
|
sta write_ay_smc3+5 ; 27
|
||||||
|
|
||||||
|
sta write_ay_smc4+2 ; 28
|
||||||
|
sta write_ay_smc4+5 ; 29
|
||||||
|
|
||||||
|
sta write_ay_smc5+2 ; 30
|
||||||
|
sta write_ay_smc5+5 ; 31
|
||||||
|
|
||||||
|
sta write_ay_smc6+2 ; 32
|
||||||
|
sta write_ay_smc6+5 ; 33
|
||||||
|
|
||||||
|
sta setup_irq_smc1+2 ; 34
|
||||||
|
sta setup_irq_smc2+2 ; 35
|
||||||
|
sta setup_irq_smc3+2 ; 36
|
||||||
|
sta setup_irq_smc4+2 ; 37
|
||||||
|
sta setup_irq_smc5+2 ; 38
|
||||||
|
sta setup_irq_smc6+2 ; 39
|
||||||
|
|
||||||
|
rts
|
||||||
|
.endif
|
||||||
|
|
||||||
|
;===================================================================
|
||||||
|
; dangerous code to patch mockingboard if not in slot#4
|
||||||
|
;===================================================================
|
||||||
|
; this code patches any $C4 value to the proper slot# if not slot4
|
||||||
|
; this can be dangerous, it might over-write other important values
|
||||||
|
; that should be $C4
|
||||||
|
|
||||||
|
; safer ways to do this:
|
||||||
|
; only do this if 2 bytes after a LDA/STA/LDX/STX
|
||||||
|
; count total and if not 39 then print error message
|
||||||
|
|
||||||
|
mockingboard_patch:
|
||||||
|
; from mockingboard_init $1BBF
|
||||||
|
; to done_pt3_irq_handler $1D85
|
||||||
|
|
||||||
|
ldx MB_ADDR_H
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
lda #<mockingboard_init
|
||||||
|
sta MB_ADDR_L
|
||||||
|
lda #>mockingboard_init
|
||||||
|
sta MB_ADDR_H
|
||||||
|
|
||||||
|
mb_patch_loop:
|
||||||
|
lda (MB_ADDR_L),Y
|
||||||
|
cmp #$C4
|
||||||
|
bne mb_patch_nomatch
|
||||||
|
|
||||||
|
txa
|
||||||
|
sta (MB_ADDR_L),Y
|
||||||
|
mb_patch_nomatch:
|
||||||
|
|
||||||
|
inc MB_ADDR_L
|
||||||
|
lda MB_ADDR_L
|
||||||
|
bne mb_patch_oflo
|
||||||
|
inc MB_ADDR_H
|
||||||
|
|
||||||
|
mb_patch_oflo:
|
||||||
|
lda MB_ADDR_H
|
||||||
|
cmp #>done_pt3_irq_handler
|
||||||
|
bne mb_patch_loop
|
||||||
|
lda MB_ADDR_L
|
||||||
|
cmp #<done_pt3_irq_handler
|
||||||
|
bne mb_patch_loop
|
||||||
|
|
||||||
|
mb_patch_done:
|
||||||
|
rts
|
||||||
|
|
||||||
|
.if 0
|
||||||
|
|
||||||
|
|
||||||
|
;=======================================
|
||||||
|
; Detect a Mockingboard card
|
||||||
|
;=======================================
|
||||||
|
; Based on code from the French Touch "Pure Noise" Demo
|
||||||
|
; Attempts to time an instruction sequence with a 6522
|
||||||
|
;
|
||||||
|
; If found, puts in bMB
|
||||||
|
; MB_ADDRL:MB_ADDRH has address of Mockingboard
|
||||||
|
; returns X=0 if not found, X=1 if found
|
||||||
|
|
||||||
|
mockingboard_detect:
|
||||||
|
lda #0
|
||||||
|
sta MB_ADDRL
|
||||||
|
|
||||||
|
mb_detect_loop: ; self-modifying
|
||||||
|
lda #$07 ; we start in slot 7 ($C7) and go down to 0 ($C0)
|
||||||
|
ora #$C0 ; make it start with C
|
||||||
|
sta MB_ADDRH
|
||||||
|
ldy #04 ; $CX04
|
||||||
|
ldx #02 ; 2 tries?
|
||||||
|
mb_check_cycle_loop:
|
||||||
|
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
|
||||||
|
; count down
|
||||||
|
sta PT3_TEMP ; 3 cycles
|
||||||
|
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||||
|
; between the two accesses to the timer
|
||||||
|
sec
|
||||||
|
sbc PT3_TEMP ; subtract to see if we had 8 cycles
|
||||||
|
cmp #$f8 ; -8
|
||||||
|
bne mb_not_in_this_slot
|
||||||
|
dex ; decrement, try one more time
|
||||||
|
bne mb_check_cycle_loop ; loop detection
|
||||||
|
inx ; Mockingboard found (X=1)
|
||||||
|
done_mb_detect:
|
||||||
|
;stx bMB ; store result to bMB
|
||||||
|
rts ; return
|
||||||
|
|
||||||
|
mb_not_in_this_slot:
|
||||||
|
dec mb_detect_loop+1 ; decrement the "slot" (self_modify)
|
||||||
|
bne mb_detect_loop ; loop down to one
|
||||||
|
ldx #00
|
||||||
|
beq done_mb_detect
|
||||||
|
|
||||||
|
;alternative MB detection from Nox Archaist
|
||||||
|
; lda #$04
|
||||||
|
; sta MB_ADDRL
|
||||||
|
; ldx #$c7
|
||||||
|
;
|
||||||
|
;find_mb:
|
||||||
|
; stx MB_ADDRH
|
||||||
|
;
|
||||||
|
; ;detect sound I
|
||||||
|
;
|
||||||
|
; sec
|
||||||
|
; ldy #$00
|
||||||
|
; lda (MB_ADDRL), y
|
||||||
|
; sbc (MB_ADDRL), y
|
||||||
|
; cmp #$05
|
||||||
|
; beq found_mb
|
||||||
|
; dex
|
||||||
|
; cpx #$c0
|
||||||
|
; bne find_mb
|
||||||
|
; ldx #$00 ;no mockingboard found
|
||||||
|
; rts
|
||||||
|
;
|
||||||
|
;found_mb:
|
||||||
|
; ldx #$01 ;mockingboard found
|
||||||
|
; rts
|
||||||
|
;
|
||||||
|
; ;optionally detect sound II
|
||||||
|
;
|
||||||
|
; sec
|
||||||
|
; ldy #$80
|
||||||
|
; lda (MB_ADDRL), y
|
||||||
|
; sbc (MB_ADDRL), y
|
||||||
|
; cmp #$05
|
||||||
|
; beq found_mb
|
||||||
|
|
||||||
|
|
||||||
|
;=======================================
|
||||||
|
; Detect a Mockingboard card in Slot4
|
||||||
|
;=======================================
|
||||||
|
; Based on code from the French Touch "Pure Noise" Demo
|
||||||
|
; Attempts to time an instruction sequence with a 6522
|
||||||
|
;
|
||||||
|
; MB_ADDRL:MB_ADDRH has address of Mockingboard
|
||||||
|
; returns X=0 if not found, X=1 if found
|
||||||
|
|
||||||
|
mockingboard_detect_slot4:
|
||||||
|
lda #0
|
||||||
|
sta MB_ADDRL
|
||||||
|
|
||||||
|
mb4_detect_loop: ; self-modifying
|
||||||
|
lda #$04 ; we're only looking in Slot 4
|
||||||
|
ora #$C0 ; make it start with C
|
||||||
|
sta MB_ADDRH
|
||||||
|
ldy #04 ; $CX04
|
||||||
|
ldx #02 ; 2 tries?
|
||||||
|
mb4_check_cycle_loop:
|
||||||
|
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
|
||||||
|
; count down
|
||||||
|
sta PT3_TEMP ; 3 cycles
|
||||||
|
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||||
|
; between the two accesses to the timer
|
||||||
|
sec
|
||||||
|
sbc PT3_TEMP ; subtract to see if we had 8 cycles
|
||||||
|
cmp #$f8 ; -8
|
||||||
|
bne mb4_not_in_this_slot
|
||||||
|
dex ; decrement, try one more time
|
||||||
|
bne mb4_check_cycle_loop ; loop detection
|
||||||
|
inx ; Mockingboard found (X=1)
|
||||||
|
done_mb4_detect:
|
||||||
|
rts ; return
|
||||||
|
|
||||||
|
mb4_not_in_this_slot:
|
||||||
|
ldx #00
|
||||||
|
beq done_mb4_detect
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.endif
|
277
graphics/hgr/vgi/pt3_lib_mockingboard_setup.s
Normal file
277
graphics/hgr/vgi/pt3_lib_mockingboard_setup.s
Normal file
|
@ -0,0 +1,277 @@
|
||||||
|
; Mockingboad programming:
|
||||||
|
; + Has two 6522 I/O chips connected to two AY-3-8910 chips
|
||||||
|
; + Optionally has some speech chips controlled via the outport on the AY
|
||||||
|
; + Often in slot 4
|
||||||
|
; TODO: how to auto-detect?
|
||||||
|
; References used:
|
||||||
|
; http://macgui.com/usenet/?group=2&id=8366
|
||||||
|
; 6522 Data Sheet
|
||||||
|
; AY-3-8910 Data Sheet
|
||||||
|
|
||||||
|
;========================
|
||||||
|
; Mockingboard card
|
||||||
|
; Essentially two 6522s hooked to the Apple II bus
|
||||||
|
; Connected to AY-3-8910 chips
|
||||||
|
; PA0-PA7 on 6522 connected to DA0-DA7 on AY
|
||||||
|
; PB0 on 6522 connected to BC1
|
||||||
|
; PB1 on 6522 connected to BDIR
|
||||||
|
; PB2 on 6522 connected to RESET
|
||||||
|
|
||||||
|
|
||||||
|
; left speaker
|
||||||
|
MOCK_6522_ORB1 = $C400 ; 6522 #1 port b data
|
||||||
|
MOCK_6522_ORA1 = $C401 ; 6522 #1 port a data
|
||||||
|
MOCK_6522_DDRB1 = $C402 ; 6522 #1 data direction port B
|
||||||
|
MOCK_6522_DDRA1 = $C403 ; 6522 #1 data direction port A
|
||||||
|
MOCK_6522_T1CL = $C404 ; 6522 #1 t1 low order latches
|
||||||
|
MOCK_6522_T1CH = $C405 ; 6522 #1 t1 high order counter
|
||||||
|
MOCK_6522_T1LL = $C406 ; 6522 #1 t1 low order latches
|
||||||
|
MOCK_6522_T1LH = $C407 ; 6522 #1 t1 high order latches
|
||||||
|
MOCK_6522_T2CL = $C408 ; 6522 #1 t2 low order latches
|
||||||
|
MOCK_6522_T2CH = $C409 ; 6522 #1 t2 high order counters
|
||||||
|
MOCK_6522_SR = $C40A ; 6522 #1 shift register
|
||||||
|
MOCK_6522_ACR = $C40B ; 6522 #1 auxilliary control register
|
||||||
|
MOCK_6522_PCR = $C40C ; 6522 #1 peripheral control register
|
||||||
|
MOCK_6522_IFR = $C40D ; 6522 #1 interrupt flag register
|
||||||
|
MOCK_6522_IER = $C40E ; 6522 #1 interrupt enable register
|
||||||
|
MOCK_6522_ORANH = $C40F ; 6522 #1 port a data no handshake
|
||||||
|
|
||||||
|
|
||||||
|
; right speaker
|
||||||
|
MOCK_6522_ORB2 = $C480 ; 6522 #2 port b data
|
||||||
|
MOCK_6522_ORA2 = $C481 ; 6522 #2 port a data
|
||||||
|
MOCK_6522_DDRB2 = $C482 ; 6522 #2 data direction port B
|
||||||
|
MOCK_6522_DDRA2 = $C483 ; 6522 #2 data direction port A
|
||||||
|
|
||||||
|
; AY-3-8910 commands on port B
|
||||||
|
; RESET BDIR BC1
|
||||||
|
MOCK_AY_RESET = $0 ; 0 0 0
|
||||||
|
MOCK_AY_INACTIVE = $4 ; 1 0 0
|
||||||
|
MOCK_AY_READ = $5 ; 1 0 1
|
||||||
|
MOCK_AY_WRITE = $6 ; 1 1 0
|
||||||
|
MOCK_AY_LATCH_ADDR = $7 ; 1 1 1
|
||||||
|
|
||||||
|
|
||||||
|
;========================
|
||||||
|
; Mockingboard Init
|
||||||
|
;========================
|
||||||
|
; Initialize the 6522s
|
||||||
|
; set the data direction for all pins of PortA/PortB to be output
|
||||||
|
|
||||||
|
mockingboard_init:
|
||||||
|
lda #$ff ; all output (1)
|
||||||
|
|
||||||
|
mock_init_smc1:
|
||||||
|
sta MOCK_6522_DDRB1
|
||||||
|
sta MOCK_6522_DDRA1
|
||||||
|
mock_init_smc2:
|
||||||
|
sta MOCK_6522_DDRB2
|
||||||
|
sta MOCK_6522_DDRA2
|
||||||
|
rts
|
||||||
|
|
||||||
|
;===================================
|
||||||
|
;===================================
|
||||||
|
; Reset Both AY-3-8910s
|
||||||
|
;===================================
|
||||||
|
;===================================
|
||||||
|
|
||||||
|
;======================
|
||||||
|
; Reset Left AY-3-8910
|
||||||
|
;======================
|
||||||
|
reset_ay_both:
|
||||||
|
lda #MOCK_AY_RESET
|
||||||
|
reset_ay_smc1:
|
||||||
|
sta MOCK_6522_ORB1
|
||||||
|
lda #MOCK_AY_INACTIVE
|
||||||
|
reset_ay_smc2:
|
||||||
|
sta MOCK_6522_ORB1
|
||||||
|
|
||||||
|
;======================
|
||||||
|
; Reset Right AY-3-8910
|
||||||
|
;======================
|
||||||
|
;reset_ay_right:
|
||||||
|
;could be merged with both
|
||||||
|
lda #MOCK_AY_RESET
|
||||||
|
reset_ay_smc3:
|
||||||
|
sta MOCK_6522_ORB2
|
||||||
|
lda #MOCK_AY_INACTIVE
|
||||||
|
reset_ay_smc4:
|
||||||
|
sta MOCK_6522_ORB2
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
; Write sequence
|
||||||
|
; Inactive -> Latch Address -> Inactive -> Write Data -> Inactive
|
||||||
|
|
||||||
|
;=========================================
|
||||||
|
; Write Right/Left to save value AY-3-8910
|
||||||
|
;=========================================
|
||||||
|
; register in X
|
||||||
|
; value in MB_VALUE
|
||||||
|
|
||||||
|
write_ay_both:
|
||||||
|
; address
|
||||||
|
|
||||||
|
write_ay_smc1:
|
||||||
|
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
|
||||||
|
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
|
||||||
|
lda #MOCK_AY_LATCH_ADDR ; latch_address on PB1 ; 2
|
||||||
|
write_ay_smc2:
|
||||||
|
sta MOCK_6522_ORB1 ; latch_address on PB1 ; 4
|
||||||
|
sta MOCK_6522_ORB2 ; latch_address on PB2 ; 4
|
||||||
|
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
|
||||||
|
write_ay_smc3:
|
||||||
|
sty MOCK_6522_ORB1 ; 4
|
||||||
|
sty MOCK_6522_ORB2 ; 4
|
||||||
|
;===========
|
||||||
|
; 28
|
||||||
|
; value
|
||||||
|
lda MB_VALUE ; 3
|
||||||
|
write_ay_smc4:
|
||||||
|
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
|
||||||
|
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
|
||||||
|
lda #MOCK_AY_WRITE ; ; 2
|
||||||
|
write_ay_smc5:
|
||||||
|
sta MOCK_6522_ORB1 ; write on PB1 ; 4
|
||||||
|
sta MOCK_6522_ORB2 ; write on PB2 ; 4
|
||||||
|
write_ay_smc6:
|
||||||
|
sty MOCK_6522_ORB1 ; 4
|
||||||
|
sty MOCK_6522_ORB2 ; 4
|
||||||
|
;===========
|
||||||
|
; 29
|
||||||
|
|
||||||
|
rts ; 6
|
||||||
|
;===========
|
||||||
|
; 63
|
||||||
|
write_ay_both_end:
|
||||||
|
;.assert >write_ay_both = >write_ay_both_end, error, "write_ay_both crosses page"
|
||||||
|
|
||||||
|
;=======================================
|
||||||
|
; clear ay -- clear all 14 AY registers
|
||||||
|
; should silence the card
|
||||||
|
;=======================================
|
||||||
|
; 7+(74*14)+5=1048
|
||||||
|
clear_ay_both:
|
||||||
|
ldx #13 ; 2
|
||||||
|
lda #0 ; 2
|
||||||
|
sta MB_VALUE ; 3
|
||||||
|
clear_ay_left_loop:
|
||||||
|
jsr write_ay_both ; 6+63
|
||||||
|
dex ; 2
|
||||||
|
bpl clear_ay_left_loop ; 3
|
||||||
|
; -1
|
||||||
|
rts ; 6
|
||||||
|
|
||||||
|
clear_ay_end:
|
||||||
|
;.assert >clear_ay_both = >clear_ay_end, error, "clear_ay_both crosses page"
|
||||||
|
|
||||||
|
;=============================
|
||||||
|
; Setup
|
||||||
|
;=============================
|
||||||
|
mockingboard_setup_interrupt:
|
||||||
|
|
||||||
|
.ifdef PT3_ENABLE_APPLE_IIC
|
||||||
|
lda APPLEII_MODEL
|
||||||
|
cmp #'C'
|
||||||
|
bne done_iic_hack
|
||||||
|
|
||||||
|
; bypass the firmware interrupt handler
|
||||||
|
; should we do this on IIe too? probably faster
|
||||||
|
|
||||||
|
; first we have to copy the ROM to the language card
|
||||||
|
|
||||||
|
sei ; disable interrupts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
copy_rom_loop:
|
||||||
|
lda $c089 ; read ROM, write RAM1
|
||||||
|
lda $c089
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
read_rom_loop:
|
||||||
|
lda $D000,Y
|
||||||
|
sta $400,Y ; note this uses text page as
|
||||||
|
; temporary data store
|
||||||
|
iny
|
||||||
|
bne read_rom_loop
|
||||||
|
|
||||||
|
lda $c08B ; read/write RAM1
|
||||||
|
lda $c08B ;
|
||||||
|
|
||||||
|
write_rom_loop:
|
||||||
|
lda $400,Y
|
||||||
|
sta $D000,Y
|
||||||
|
iny
|
||||||
|
bne write_rom_loop
|
||||||
|
|
||||||
|
inc read_rom_loop+2
|
||||||
|
inc write_rom_loop+5
|
||||||
|
bne copy_rom_loop
|
||||||
|
|
||||||
|
lda #<interrupt_handler
|
||||||
|
sta $fffe
|
||||||
|
lda #>interrupt_handler
|
||||||
|
sta $ffff
|
||||||
|
|
||||||
|
lda #$EA ; nop out the "lda $45" in the irq handler
|
||||||
|
sta interrupt_smc
|
||||||
|
sta interrupt_smc+1
|
||||||
|
.endif
|
||||||
|
|
||||||
|
done_iic_hack:
|
||||||
|
|
||||||
|
|
||||||
|
;=========================
|
||||||
|
; Setup Interrupt Handler
|
||||||
|
;=========================
|
||||||
|
; Vector address goes to 0x3fe/0x3ff
|
||||||
|
; FIXME: should chain any existing handler
|
||||||
|
|
||||||
|
lda #<interrupt_handler
|
||||||
|
sta $03fe
|
||||||
|
lda #>interrupt_handler
|
||||||
|
sta $03ff
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; Enable 50Hz clock on 6522
|
||||||
|
;============================
|
||||||
|
|
||||||
|
|
||||||
|
; Note, on Apple II the clock isn't 1MHz but is actually closer to
|
||||||
|
; roughly 1.023MHz, and every 65th clock is stretched (it's complicated)
|
||||||
|
|
||||||
|
; 4fe7 / 1.023e6 = .020s, 50Hz
|
||||||
|
; 9c40 / 1.023e6 = .040s, 25Hz
|
||||||
|
; 411a / 1.023e6 = .016s, 60Hz
|
||||||
|
|
||||||
|
; French Touch uses
|
||||||
|
; 4e20 / 1.000e6 = .020s, 50Hz, which assumes 1MHz clock freq
|
||||||
|
|
||||||
|
sei ; disable interrupts just in case
|
||||||
|
|
||||||
|
lda #$40 ; Continuous interrupts, don't touch PB7
|
||||||
|
setup_irq_smc1:
|
||||||
|
sta MOCK_6522_ACR ; ACR register
|
||||||
|
lda #$7F ; clear all interrupt flags
|
||||||
|
setup_irq_smc2:
|
||||||
|
sta MOCK_6522_IER ; IER register (interrupt enable)
|
||||||
|
|
||||||
|
lda #$C0
|
||||||
|
setup_irq_smc3:
|
||||||
|
sta MOCK_6522_IFR ; IFR: 1100, enable interrupt on timer one oflow
|
||||||
|
setup_irq_smc4:
|
||||||
|
sta MOCK_6522_IER ; IER: 1100, enable timer one interrupt
|
||||||
|
|
||||||
|
lda #$E7
|
||||||
|
; lda #$20
|
||||||
|
setup_irq_smc5:
|
||||||
|
sta MOCK_6522_T1CL ; write into low-order latch
|
||||||
|
lda #$4f
|
||||||
|
; lda #$4E
|
||||||
|
setup_irq_smc6:
|
||||||
|
sta MOCK_6522_T1CH ; write into high-order latch,
|
||||||
|
; load both values into counter
|
||||||
|
; clear interrupt and start counting
|
||||||
|
|
||||||
|
rts
|
|
@ -72,3 +72,24 @@ vgi_line:
|
||||||
jsr HGLIN ; line to (X,A),(Y)
|
jsr HGLIN ; line to (X,A),(Y)
|
||||||
|
|
||||||
jmp vgi_loop
|
jmp vgi_loop
|
||||||
|
|
||||||
|
;========================
|
||||||
|
; VGI LINE FAR
|
||||||
|
;========================
|
||||||
|
; assume second x-coord is > 256
|
||||||
|
; VGI_LX = P0
|
||||||
|
; VGI_LY = P1
|
||||||
|
; VGI_LX2 = P3
|
||||||
|
; VGI_LY2 = P4
|
||||||
|
|
||||||
|
vgi_line_far:
|
||||||
|
jsr vgi_point_common
|
||||||
|
|
||||||
|
ldx #1
|
||||||
|
ldy VGI_LY2
|
||||||
|
lda VGI_LX2
|
||||||
|
|
||||||
|
jsr HGLIN ; line to (X,A),(Y)
|
||||||
|
|
||||||
|
jmp vgi_loop
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,43 @@
|
||||||
; zero page
|
; zero page
|
||||||
|
|
||||||
|
;; Zero page addresses
|
||||||
|
|
||||||
|
ORNAMENT_L = $60
|
||||||
|
ORNAMENT_H = $61
|
||||||
|
SAMPLE_L = $62
|
||||||
|
SAMPLE_H = $63
|
||||||
|
|
||||||
|
LOOP = $64
|
||||||
|
MB_ADDR_L = $65
|
||||||
|
MB_ADDR_H = $66
|
||||||
|
MB_VALUE = $67
|
||||||
|
DONE_PLAYING = $68
|
||||||
|
DONE_SONG = $69
|
||||||
|
PT3_TEMP = $6A
|
||||||
|
APPLEII_MODEL = $6B
|
||||||
|
|
||||||
|
AY_REGISTERS = $50
|
||||||
|
A_FINE_TONE = $50
|
||||||
|
A_COARSE_TONE = $51
|
||||||
|
B_FINE_TONE = $52
|
||||||
|
B_COARSE_TONE = $53
|
||||||
|
C_FINE_TONE = $54
|
||||||
|
C_COARSE_TONE = $55
|
||||||
|
NOISE = $56
|
||||||
|
ENABLE = $57
|
||||||
|
PT3_MIXER_VAL = $57
|
||||||
|
A_VOLUME = $58
|
||||||
|
B_VOLUME = $59
|
||||||
|
C_VOLUME = $5A
|
||||||
|
ENVELOPE_FINE = $5B
|
||||||
|
ENVELOPE_COARSE = $5C
|
||||||
|
ENVELOPE_SHAPE = $5D
|
||||||
|
|
||||||
|
PATTERN_L = $5E
|
||||||
|
PATTERN_H = $5F
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HGR_X = $E0
|
HGR_X = $E0
|
||||||
HGR_XH = $E1
|
HGR_XH = $E1
|
||||||
HGR_Y = $E2
|
HGR_Y = $E2
|
||||||
|
|
37
music/pt3_lib/pt3_lib_detect_model.s
Normal file
37
music/pt3_lib/pt3_lib_detect_model.s
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
;===========================
|
||||||
|
; Check for Apple IIc
|
||||||
|
;===========================
|
||||||
|
|
||||||
|
|
||||||
|
; ' ' ($20) = Apple II
|
||||||
|
; '+' ($2B) = Apple II+
|
||||||
|
; 'E' ($45) = Apple IIe
|
||||||
|
; 'C' ($43) = Apple IIc
|
||||||
|
; 'G' ($47) = Apple IIgs
|
||||||
|
|
||||||
|
; it does interrupts differently
|
||||||
|
detect_appleii_model:
|
||||||
|
lda #' '
|
||||||
|
sta APPLEII_MODEL
|
||||||
|
|
||||||
|
lda $FBB3 ; IIe and newer is $06
|
||||||
|
cmp #6
|
||||||
|
beq apple_iie_or_newer
|
||||||
|
|
||||||
|
; TODO: check for II+
|
||||||
|
|
||||||
|
jmp done_apple_detect
|
||||||
|
|
||||||
|
apple_iie_or_newer:
|
||||||
|
|
||||||
|
; TODO: check for IIe
|
||||||
|
|
||||||
|
lda $FBC0 ; 0 on a IIc
|
||||||
|
bne done_apple_detect
|
||||||
|
apple_iic:
|
||||||
|
lda #'C'
|
||||||
|
sta APPLEII_MODEL
|
||||||
|
|
||||||
|
done_apple_detect:
|
||||||
|
|
||||||
|
rts
|
Loading…
Reference in New Issue
Block a user