second: merge in fake bios

This commit is contained in:
Vince Weaver 2023-10-06 00:21:16 -04:00
parent 1fabebdd3a
commit ab1d8992dc
16 changed files with 1707 additions and 24 deletions

View File

@ -1,14 +1,14 @@
;; HARDWARE LOCATIONS
; HARDWARE LOCATIONS
KEYPRESS = $C000
KEYRESET = $C010
;; SOFT SWITCHES
; SOFT SWITCHES
CLR80COL = $C000 ; PAGE1/PAGE1 normal
SET80COL = $C001 ; PAGE1/PAGE2 switches PAGE1 in Aux instead
EIGHTYCOLOFF = $C00C
EIGHTYCOLON = $C00D
TBCOLOR = $C022 ; IIgs fg/bg colors
TBCOLOR = $C022 ; IIgs text fg/bg colors
NEWVIDEO = $C029 ; IIgs graphics modes
SPEAKER = $C030
CLOCKCTL = $C034 ; bits 0-3 are IIgs border color
@ -26,32 +26,40 @@ PADDLE_BUTTON0 = $C061
PADDL0 = $C064
PTRIG = $C070
;; BASIC ROUTINES
; APPLESOFT BASIC ROUTINES
NORMAL = $F273
NORMAL = $F273
HGR2 = $F3D8
HGR = $F3E2
BKGND0 = $F3F4 ; clear current page to A
HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y)
HPLOT0 = $F457 ; plot at (Y,X), (A)
COLOR_SHIFT = $F47E
HLINRL = $F530 ; (X,A),(Y)
HGLIN = $F53A ; line to (X,A),(Y)
COLORTBL = $F6F6
;; MONITOR ROUTINES
; MONITOR ROUTINES
HLINE = $F819 ;; HLINE Y,$2C at A
VLINE = $F828 ;; VLINE A,$2D at Y
CLRSCR = $F832 ;; Clear low-res screen
CLRTOP = $F836 ;; clear only top of low-res screen
SETCOL = $F864 ;; COLOR=A
ROM_TEXT2COPY = $F962 ;; iigs
HLINE = $F819 ; HLINE Y,$2C at A
VLINE = $F828 ; VLINE A,$2D at Y
CLRSCR = $F832 ; Clear low-res screen
CLRTOP = $F836 ; clear only top of low-res screen
SETCOL = $F864 ; COLOR=A
ROM_TEXT2COPY = $F962 ; iigs
TEXT = $FB36
TABV = $FB5B ;; VTAB to A
ROM_MACHINEID = $FBB3 ;; iigs
BASCALC = $FBC1 ;;
VTAB = $FC22 ;; VTAB to CV
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
SETINV = $FE80 ;; INVERSE
SETNORM = $FE84 ;; NORMAL
COUT = $FDED ;; output A to screen
COUT1 = $FDF0 ;; output A to screen
TABV = $FB5B ; VTAB to A
ROM_MACHINEID = $FBB3 ; iigs
BASCALC = $FBC1 ;
BELL = $FBDD ; ring the bell
VTAB = $FC22 ; VTAB to CV
HOME = $FC58 ; Clear the text screen
WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
SETINV = $FE80 ; INVERSE
SETNORM = $FE84 ; NORMAL
COUT = $FDED ; output A to screen
COUT1 = $FDF0 ; output A to screen
HGR2 = $F3D8
HGR = $F3E2

View File

@ -0,0 +1,10 @@
; relies on different behavior of decimal mode on 6502 vs 65c02
detect_65c02:
sed ; set decimal mode
clc ; clear carry for add
lda #$99 ; 99 decimal
adc #$01 ; +1 gives 00 and sets Z on 65C02
cld ; exit decimal mode
rts

View File

@ -0,0 +1,29 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
DOS33_RAW = ../../../utils/dos33fs-utils/dos33_raw
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
LINKER_SCRIPTS = ../../../linker_scripts
EMPTY_DISK = ../../../empty_disk
all: FAKE_BIOS
###
FAKE_BIOS: fake_bios.o
ld65 -o FAKE_BIOS fake_bios.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
fake_bios.o: fake_bios.s \
hgr_clear_screen.s \
font_console_1x8.s fonts/a2_cga_thin.inc \
pt3_lib_detect_model.s ../lc_detect.s aux_detect.s \
65c02_detect.s ../pt3_lib_mockingboard_detect.s \
pt3_lib_mockingboard_setup.s ../wait.s \
../zx02_optim.s graphics/a2_energy.hgr.zx02
ca65 -o fake_bios.o fake_bios.s -l fake_bios.lst
###
clean:
rm -f *~ *.o *.lst FAKE_BIOS

View File

@ -0,0 +1,51 @@
detect_aux_ram:
; if Apple IIgs or IIc assume 128k
; FIXME: Apple IIgs there are routines to get more accurate count
lda APPLEII_MODEL
cmp #'g'
beq return_64k
cmp #'c'
beq return_64k
cmp #'e'
bne return_0k ; assume none if not IIe
; enable AUX zp
sta $C009
; write $AA to $FF FF:AUX = AA, FF:MAIN=??
lda #$AA
sta $FF
; disable AUX zp
sta $C008
; write $55 to $FF FF:AUX=AA, FF:MAIN=55
lda #$55
sta $FF
; enable AUX zp
sta $C009
ldx $FF
; disable AUX zp ; if aux, then X=AA, else X=55
sta $C008
cpx #$AA
bne return_0k
return_64k:
lda #64
rts
return_1k:
lda #1
rts
return_0k:
lda #0
rts

View File

@ -0,0 +1,764 @@
; Fake BIOS screen
; for another project
.include "../zp.inc"
.include "../hardware.inc"
bios_test:
;===================
; set graphics mode
;===================
jsr HOME
bit HIRES
bit FULLGR
bit SET_GR
bit PAGE1
jsr build_tables
;=======================
; Hardware Detect Model
;=======================
; Yes Michaelangel007 I will eventually update linux_logo 6502
jsr detect_appleii_model
lda APPLEII_MODEL
cmp 'g'
bne not_iigs
is_a_iigs:
; set background color to black instead of blue
lda NEWVIDEO
and #%00011111 ; bit 7 = 0 -> IIgs Apple II-compat video modes
; bit 6 = 0 -> IIgs 128K memory map same as IIe
; bit 5 = 0 -> IIgs DHGR is color, not mono
; bits 0-4 unchanged
sta NEWVIDEO
lda #$F0
sta TBCOLOR ; white text on black background
lda #$00
sta CLOCKCTL ; black border
sta CLOCKCTL ; set twice for VidHD
lda #'s'
sta model_patch_1+9
lda #'C'
sta cpu_patch_1+14
sta cpu_patch_2+2
lda #'8'
sta cpu_patch_1+15
sta cpu_patch_2+3
lda #'1'
sta cpu_patch_1+16
sta cpu_patch_2+4
lda #'6'
sta cpu_patch_1+17
sta cpu_patch_2+5
not_iigs:
; update text printed
lda APPLEII_MODEL
cmp #'3'
bne no_not_a_iii
lda #'/' ; 3 slashes
sta model_patch_1+6
sta model_patch_1+7
sta model_patch_1+8
bne hardware_detect_ram ; bra
no_not_a_iii:
lda APPLEII_MODEL
sta model_patch_1+8 ; patch to ' ' '+' 'e' 'c' or 'g'
;=======================
; Hardware Detect RAM
;=======================
hardware_detect_ram:
;=================================================
; assume 48k for base model (not necessarily true)
lda #48 ; FIXME: detect less on earlier models?
sta TOTAL_RAM
;================================================
; detect language card 16k
; could cheat and just make it 64k in this case
; can you have a language card on a 4k system?
jsr detect_language_card
bcs ram_no_lc
ram_yes_lc:
; carry clear here
lda #16
adc TOTAL_RAM
sta TOTAL_RAM
; update text string
lda #'1'
sta lang_card_patch+34
lda #'6'
sta lang_card_patch+35
ram_no_lc:
;================================================
; detect aux memory
; iigs we're lazy and say 64k
; iic always 64k AUX
; iie we have to probe
; in theory can have 0k, 1k or 64k of it
jsr detect_aux_ram
cmp #0
beq ram_no_aux
cmp #1
beq ram_1k_aux
ram_64k_aux:
clc
lda TOTAL_RAM
adc #64
sta TOTAL_RAM
lda #'6'
sta aux_mem_patch+34
lda #'4'
sta aux_mem_patch+35
bne ram_done_aux ; bra
ram_1k_aux:
inc TOTAL_RAM
lda #'1'
sta aux_mem_patch+35
ram_no_aux:
ram_done_aux:
;====================
; detect CPU
;====================
lda APPLEII_MODEL
cmp #'g' ; already handled IIgs
beq done_detect_cpu
jsr detect_65c02
bne was_not_65c02
lda #'C'
sta cpu_patch_1+14
sta cpu_patch_2+2
lda #'0'
sta cpu_patch_1+15
sta cpu_patch_2+3
lda #'2'
sta cpu_patch_1+16
sta cpu_patch_2+4
was_not_65c02:
done_detect_cpu:
;====================
; detect disk slot
;====================
; this depends on DOS3.3 loading
lda $B5F7 ; slot*16
lsr
lsr
lsr
lsr
adc #'0'
sta slot_patch1+1
sta slot_patch2+1
sta slot_patch3+1
sta slot_patch5+7
sta slot_patch6+7
;=====================
; Detect mockingboard
;=====================
lda #0
sta SOUND_STATUS
PT3_ENABLE_APPLE_IIC = 1
jsr mockingboard_detect
bcc mockingboard_notfound
mockingboard_found:
lda MB_ADDR_H
and #$7
ora #$30
sta mock_slot_patch+7
lda SOUND_STATUS
ora #SOUND_MOCKINGBOARD
sta SOUND_STATUS
mockingboard_notfound:
;===================
; Load graphics
;===================
lda #<graphics_data
sta ZX0_src
lda #>graphics_data
sta ZX0_src+1
lda #$20 ; temporarily load to $2000
jsr zx02_full_decomp
; Bios screen 1
lda #0
sta CH
sta CV
lda #<bios_message_1
ldy #>bios_message_1
ldx #5
jsr draw_multiple_strings
lda #0
sta CH
lda #176
sta CV
lda #<bios_message_1a
ldy #>bios_message_1a
ldx #2
jsr draw_multiple_strings
;=========================
; do fake memory count
lda TOTAL_RAM
sta MEMCOUNT
memcount_loop:
lda KEYPRESS ; 4
bmi done_memcount ; 3
lda #100
jsr wait
jsr increment_memory
dec MEMCOUNT
bne memcount_loop
done_memcount:
bit KEYRESET ; clear the keyboard buffer
bit $C0E9 ; turn on drive motor (slot6)
; TODO: drive2 as well?
ldx #200
jsr long_wait
bit $C0E8 ; turn off drive motor (slot6)
;==============================
; print system config screen
;==============================
; TODO:
; clear/fade the energy star logo first
; clear offscreen so no blinds effect
lda #$cc
jsr fade_logo_mask
lda #200
jsr wait
lda #$33
jsr fade_logo_mask
lda #200
jsr wait
; clear screen while offscreen
; avoid blinds effect
jsr hgr_page2_clearscreen
bit PAGE2
jsr hgr_page1_clearscreen
bit PAGE1
jsr BELL
; print first part of message
lda #10
sta CH
lda #0
sta CV
lda #<bios_message_2
ldy #>bios_message_2
ldx #8
jsr draw_multiple_strings
; optionally print mockingboard text
lda SOUND_STATUS
beq print_rest
jsr DrawCondensedStringAgain
print_rest:
; print rest
lda #<super_serial_text
ldy #>super_serial_text
ldx #2
jsr draw_multiple_strings
ldx #10
jsr long_wait
;====================
; print DOS string
;====================
jsr DrawCondensedStringAgain
ldx #10
jsr long_wait
;====================
; type the CD command
;====================
ldx #17
jsr draw_dos_command
jsr DrawCondensedStringAgain
;====================
; type the DIR command
;====================
jsr DrawCondensedStringAgain
ldx #6
jsr draw_dos_command
jsr DrawCondensedStringAgain
;====================
; show DIR
;====================
bit $C0E9 ; turn on drive motor (slot6)
lda #<bios_message_6
ldy #>bios_message_6
ldx #7
jsr draw_multiple_strings
bit $C0E8 ; turn off drive motor (slot6)
;=======================
; type the LEMM command
;=======================
ldx #5
jsr draw_dos_command
end:
jmp end
; 0123456789012345678901234567890123456789
bios_message_1:
.byte "Apple II Modular BIOS",13,0
.byte "Copyright (C) 1977-1991",13,13,0
model_patch_1: ; +8
.byte "Apple II ",13,13,0
cpu_patch_2: ; +2
.byte "6502 CPU at 1.023MHz",13,0
.byte "Memory Test: 0B OK",13,0
bios_message_1a:
.byte "Press ",$17,"-D to enter SETUP",13,0
.byte "02/13/78-6502-564D57",0
bios_message_2:
.byte "System Configuration",13,0
.byte $1D ; 0,8
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$15,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E
.byte $1C, 13,0
cpu_patch_1: ; +14
.byte $1F," CPU Type: 6502 ",$14," Base Memory: 48K ",$1F,13,0 ; 16
lang_card_patch: ; +34
.byte $1F," Co-Proc: NONE ",$14," Lang Card: 0K ",$1F,13,0 ; 24
aux_mem_patch: ; +34
.byte $1F," Clock: 1.023MHz ",$14," AUX Memory: 0K ",$1F,13,0 ; 32
.byte $19 ; 40
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$13,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E
.byte $18, 13, 0
disk_text:
slot_patch5: ;+7
.byte $1F," Slot 6 Disk 1: Disk II 140K ",$1F,13,0 ; 48
slot_patch6:
.byte $1F," Slot 6 Disk 2: Disk II 140K ",$1F,13,0 ; 56
mockingboard_text:
mock_slot_patch: ; +7
.byte $1F," Slot 4 : VIA 6522/Mockingboard ",$1F,13,0 ; 64
super_serial_text:
.byte $1F," Slot 1 : Super Serial Card ",$1F,13,0 ; 72
.byte $1B ; 80
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E
.byte $1E,$1E,$1E,$1E,$1E,$1E
.byte $1A, 13,0
bios_message3:
.byte "Starting DOS 3.3...",13,13,0 ; 88
bios_message4:
slot_patch1:
.byte "S6D1>",0 ; 104
.byte "c",0
.byte "d",0
.byte " ",0
.byte "g",0
.byte "a",0
.byte "m",0
.byte "e",0
.byte "s",0
.byte "\",0
.byte "l",0
.byte "e",0
.byte "m",0
.byte "m",0
.byte "i",0
.byte "n",0
.byte "g",0
.byte "s",13,0
bios_message5:
.byte 13,0
slot_patch2:
.byte "S6D1>",0 ; 112
.byte "d",0
.byte "i",0
.byte "r",0
.byte " ",0
.byte "/",0
.byte "w",13,0
bios_message_6:
.byte "Directory of s6d1:\games\lemmings\.",13,0 ; 128
.byte "[.] [..] QBOOT QLOAD",13,0
.byte "LEVEL1 LEVEL2 LEVEL3 LEVEL4",13,0
.byte "LEVEL5 LEVEL6 LEVEL7 LEVEL8",13,0
.byte "LEVEL9 LEVEL10 LEMM",13,0
.byte " 13 File(s) 90,624 Bytes.",13,0
.byte " 2 Dir(s) 52,736 Bytes free.",13,13,0
bios_message7:
slot_patch3:
.byte "S6D1>",0 ; 184
.byte "l",0
.byte "e",0
.byte "m",0
.byte "m",0
.include "font_console_1x8.s"
.include "fonts/a2_cga_thin.inc"
.include "../zx02_optim.s"
graphics_data:
.incbin "graphics/a2_energy.hgr.zx02"
hposn_low = $1713 ; 0xC0 bytes (lifetime, used by DrawLargeCharacter)
hposn_high = $1800 ; 0xC0 bytes (lifetime, used by DrawLargeCharacter)
.include "hgr_table.s"
wait_until_keypress:
lda KEYPRESS ; 4
bpl wait_until_keypress ; 3
bit KEYRESET ; clear the keyboard buffer
rts ; 6
memcount:
.byte $00,$00,$00
memcount_string:
; .byte 13,48,
.byte $00,$00,$00,$00,$00,$00,0
;================================
;================================
;================================
;================================
increment_memory:
sed
clc
lda memcount+2
adc #$24
sta memcount+2
lda memcount+1
adc #$10
sta memcount+1
lda memcount
adc #0
sta memcount
cld
; copy to output buffer
ldx #0
stx INL
stx LEAD0
do_memcount_loop:
memcount_top_nibble:
lda memcount,X
lsr
lsr
lsr
lsr
bne tn_display_digit
ldy LEAD0
bne tn_display_digit
tn_no_display_digit:
lda #$20 ; space
bne tn_actually_display_digit
tn_display_digit:
clc
adc #$30
sta LEAD0
tn_actually_display_digit:
ldy INL
sta memcount_string,Y
inc INL
memcount_bottom_nibble:
lda memcount,X
and #$f
bne display_digit
ldy LEAD0
bne display_digit
no_display_digit:
lda #$20 ; space
bne actually_display_digit
display_digit:
clc
adc #$30
sta LEAD0
actually_display_digit:
ldy INL
sta memcount_string,Y
inc INL
inx
cpx #3
bne do_memcount_loop
bit SPEAKER
lda #13
sta CH
lda #48
sta CV
lda #<memcount_string
ldy #>memcount_string
jmp DrawCondensedString ; tail call
;==============================
;==============================
;==============================
;==============================
draw_multiple_strings:
dex
stx STRING_COUNT
jsr DrawCondensedString
multiple_loop:
jsr DrawCondensedStringAgain
dec STRING_COUNT
bne multiple_loop
rts
;==============================
;==============================
;==============================
;==============================
draw_dos_command:
stx STRING_COUNT
dos_command_loop:
jsr DrawCondensedStringAgain
lda OUTL
pha
lda OUTH
pha
dos_command_inner:
; draw curosr
lda #<dos_cursor
ldy #>dos_cursor
jsr DrawCondensedString
dec CH
lda #200
jsr wait
lda KEYPRESS
bmi dos_keypress
jsr DrawCondensedStringAgain
dec CH
lda #200
jsr wait
lda KEYPRESS
bmi dos_keypress
jmp dos_command_inner
dos_keypress:
bit KEYRESET
lda #<dos_space
ldy #>dos_space
jsr DrawCondensedString
dec CH
pla
sta OUTH
pla
sta OUTL
dec STRING_COUNT
bne dos_command_loop
rts
dos_cursor:
.byte "_",0
dos_space:
.byte " ",0
;=======================
;=======================
;=======================
; 210,0 to 210,64
fade_logo_mask:
sta mask_smc+1
fade_logo:
ldx #63
outer_loop:
lda hposn_low,X
sta inner_loop_smc1+1
sta inner_loop_smc2+1
lda hposn_high,X
sta inner_loop_smc1+2
sta inner_loop_smc2+2
ldy #39
inner_loop:
inner_loop_smc1:
lda $2000,Y
mask_smc:
and #$CC
inner_loop_smc2:
sta $2000,Y
dey
cpy #29
bne inner_loop
dex
bpl outer_loop
rts
; in X
long_wait:
lda #200
jsr wait
lda KEYPRESS
bmi early_out
dex
bne long_wait
early_out:
bit KEYRESET
rts
.include "hgr_clear_screen.s"
.include "pt3_lib_detect_model.s"
.include "../lc_detect.s"
.include "aux_detect.s"
.include "65c02_detect.s"
.include "pt3_lib_mockingboard_setup.s"
.include "../pt3_lib_mockingboard_detect.s"
.include "../wait.s"

View File

@ -0,0 +1,251 @@
;license:MIT
;(c) 2023 by 4am
;
; drawing routines for Million Perfect Tiles Condensed
;
; Public functions:
; - DrawCondensedString
;
; VMW: commented, reformatted, minor changes, ca65 assembly
; hacked up some more
FONT_OFFSET = $13
;------------------------------------------------------------------------------
; DrawCondensedString
;
; in: A/Y points to zero terminated string, with x-pos and y-pos at start
; out: clobbers all registers & flags
;------------------------------------------------------------------------------
DrawCondensedString:
; store the string location
sta OUTL
sty OUTH
DrawCondensedStringAgain:
lda OUTL
sta dcb_loop_smc+1
lda OUTH
sta dcb_loop_smc+2
ldy CV
; row0
lda hposn_low, Y ; get low memory offset
clc
adc CH ; add in x-coord
sta dcb_row0+4
lda hposn_high, Y ; get high memory offset
sta dcb_row0+5 ; save it out
iny ; go to next row
; row1
lda hposn_low, Y
adc CH
sta dcb_row1+4
lda hposn_high, Y
sta dcb_row1+5
iny
; row2
lda hposn_low, Y
adc CH
sta dcb_row2+4
lda hposn_high, Y
sta dcb_row2+5
iny
; row3
lda hposn_low, Y
adc CH
sta dcb_row3+4
lda hposn_high, Y
sta dcb_row3+5
iny
; row4
lda hposn_low, Y
adc CH
sta dcb_row4+4
lda hposn_high, Y
sta dcb_row4+5
iny
; row5
lda hposn_low, Y
adc CH
sta dcb_row5+4
lda hposn_high, Y
sta dcb_row5+5
iny
; row6
lda hposn_low, Y
adc CH
sta dcb_row6+4
lda hposn_high, Y
sta dcb_row6+5
iny
; row7
lda hposn_low, Y
adc CH
sta dcb_row7+4
lda hposn_high, Y
sta dcb_row7+5
ldx #0
dcb_loop:
dcb_loop_smc:
ldy $FDFD, X ; load next char into Y
beq dcb_done
cpy #13
bne not_linefeed
lda #0
sta CH
clc
lda CV
adc #8
sta CV
inx
lda CV
cmp #192
bcc dcb_loop
lda #184
sta CV
stx XSAVE
jsr scroll_screen
ldx XSAVE
jmp dcb_loop
not_linefeed:
; unrolled loop to write out each line
dcb_row0:
lda CondensedRow0-FONT_OFFSET, Y ; get 1-byte font row
sta $FDFD, X ; write out to graphics mem
dcb_row1:
lda CondensedRow1-FONT_OFFSET, Y
sta $FDFD, X
dcb_row2:
lda CondensedRow2-FONT_OFFSET, Y
sta $FDFD, X
dcb_row3:
lda CondensedRow3-FONT_OFFSET, Y
sta $FDFD, X
dcb_row4:
lda CondensedRow4-FONT_OFFSET, Y
sta $FDFD, X
dcb_row5:
lda CondensedRow5-FONT_OFFSET, Y
sta $FDFD, X
dcb_row6:
lda CondensedRow6-FONT_OFFSET, Y
sta $FDFD, X
dcb_row7:
lda CondensedRow7-FONT_OFFSET, Y
sta $FDFD, X
inc CH
inx ; move to next
bne dcb_loop ; bra (well, as long as string
; is less than 255 chars)
dcb_done:
; point to location after
sec ; always add 1
txa
adc OUTL
sta OUTL
lda #0
adc OUTH
sta OUTH
rts
;================================
;================================
; scroll_screen
;================================
;================================
; scrolls hgr page1 up by 8, filling with empty space at bottom
; trashes A,X,Y
scroll_screen:
ldx #8
stx SCROLL_IN
ldx #0
stx SCROLL_OUT
scroll_yloop:
ldx SCROLL_IN
lda hposn_low,X
sta xloop_smc1+1
lda hposn_high,X
sta xloop_smc1+2
ldx SCROLL_OUT
lda hposn_low,X
sta xloop_smc2+1
lda hposn_high,X
sta xloop_smc2+2
ldy #39
scroll_xloop:
xloop_smc1:
lda $2000,Y
xloop_smc2:
sta $2000,Y
dey
bpl scroll_xloop
inc SCROLL_IN
inc SCROLL_OUT
lda SCROLL_IN
cmp #192
bne scroll_yloop
; blank bottom line
lda #$00
ldy #39
scroll_hline_xloop:
sta $23D0,Y
sta $27D0,Y
sta $2BD0,Y
sta $2FD0,Y
sta $33D0,Y
sta $37D0,Y
sta $3BD0,Y
sta $3FD0,Y
dey
bpl scroll_hline_xloop
rts

View File

@ -0,0 +1,10 @@
PNG2FONT = ../../../../utils/hgr-utils/png2font
all: a2_cga_thin.inc
a2_cga_thin.inc: a2_cga_thin.png
$(PNG2FONT) -i -o 0x13 a2_cga_thin.png > a2_cga_thin.inc
clean:
rm -f *~ *.inc

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -0,0 +1,23 @@
include ../../../../Makefile.inc
ZX02 = ~/research/6502_compression/zx02.git/build/zx02 -f
PNG_TO_HGR = ../../../../utils/hgr-utils/png2hgr
PNG2GR = ../../../../utils/gr-utils/png2gr
PNG2SPRITES = ../../../../utils/gr-utils/png2sprites
HGR_SPRITE = ../../../../utils/hgr-utils/hgr_make_sprite
all: a2_energy.hgr.zx02
####
a2_energy.hgr.zx02: a2_energy.hgr
$(ZX02) a2_energy.hgr a2_energy.hgr.zx02
a2_energy.hgr: a2_energy.png
$(PNG_TO_HGR) a2_energy.png > a2_energy.hgr
####
clean:
rm -f *~ *.o *.zx02 *.lst

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

View File

@ -0,0 +1,84 @@
hgr_page1_clearscreen:
ldy #0
hgr_page1_cls_loop:
sta $2000,Y
sta $2100,Y
sta $2200,Y
sta $2300,Y
sta $2400,Y
sta $2500,Y
sta $2600,Y
sta $2700,Y
sta $2800,Y
sta $2900,Y
sta $2A00,Y
sta $2B00,Y
sta $2C00,Y
sta $2D00,Y
sta $2E00,Y
sta $2F00,Y
sta $3000,Y
sta $3100,Y
sta $3200,Y
sta $3300,Y
sta $3400,Y
sta $3500,Y
sta $3600,Y
sta $3700,Y
sta $3800,Y
sta $3900,Y
sta $3A00,Y
sta $3B00,Y
sta $3C00,Y
sta $3D00,Y
sta $3E00,Y
sta $3F00,Y
iny
bne hgr_page1_cls_loop
rts
hgr_page2_clearscreen:
ldy #0
hgr_page2_cls_loop:
sta $4000,Y
sta $4100,Y
sta $4200,Y
sta $4300,Y
sta $4400,Y
sta $4500,Y
sta $4600,Y
sta $4700,Y
sta $4800,Y
sta $4900,Y
sta $4A00,Y
sta $4B00,Y
sta $4C00,Y
sta $4D00,Y
sta $4E00,Y
sta $4F00,Y
sta $5000,Y
sta $5100,Y
sta $5200,Y
sta $5300,Y
sta $5400,Y
sta $5500,Y
sta $5600,Y
sta $5700,Y
sta $5800,Y
sta $5900,Y
sta $5A00,Y
sta $5B00,Y
sta $5C00,Y
sta $5D00,Y
sta $5E00,Y
sta $5F00,Y
iny
bne hgr_page2_cls_loop
rts

View File

@ -0,0 +1,37 @@
; hposn_low, hposn_high will each be filled with $C0 bytes
; based on routine by John Brooks
; posted on comp.sys.apple2 on 2018-07-11
; https://groups.google.com/d/msg/comp.sys.apple2/v2HOfHOmeNQ/zD76fJg_BAAJ
; clobbers A,X
; preserves Y
; vmw note: version I was using based on applesoft HPOSN was ~64 bytes
; this one is 37 bytes
build_tables:
ldx #0
btmi:
txa
and #$F8
bpl btpl1
ora #5
btpl1:
asl
bpl btpl2
ora #5
btpl2:
asl
asl
sta hposn_low, X
txa
and #7
rol
asl hposn_low, X
rol
ora #$20
sta hposn_high, X
inx
cpx #$C0
bne btmi
rts

View File

@ -0,0 +1,87 @@
;===========================
; Check Apple II model
;===========================
; this is mostly for IIc support
; as it does interrupts differently
; some of this info from the document:
; Apple II Family Identification Routines 2.2
;
; ' ' = Apple II
; '+' = Apple II+
; 'e' = Apple IIe
; 'c' = Apple IIc
; 'g' = Apple IIgs
; 'm' = mac L/C with board
; 'j' = jplus
; '3' = Apple III
detect_appleii_model:
lda #' '
ldx $FBB3
; II is $38
; J-plus is $C9
; II+ is $EA (so is III)
; IIe and newer is $06
cpx #$38 ; ii
beq done_apple_detect
; ii+ is EA FB1E=AD
; iii is EA FB1E=8A 00
cpx #$EA
bne not_ii_iii
ii_or_iii:
lda #'+' ; ii+/iii
ldx $FB1E
cpx #$AD
beq done_apple_detect ; ii+
lda #'3'
bne done_apple_detect ; bra iii
not_ii_iii:
lda #'j' ; jplus
cpx #$C9
beq done_apple_detect
cpx #$06
bne done_apple_detect
apple_iie_or_newer:
ldx $FBC0 ; $EA on a IIe
; $E0 on a IIe enhanced
; $00 on a IIc/IIc+
; $FE1F = $60, IIgs
beq apple_iic
lda #'e'
cpx #$EA
beq done_apple_detect
cpx #$E0
beq done_apple_detect
; assume GS?
lda #'g'
bne done_apple_detect
apple_iic:
lda #'c'
done_apple_detect:
sta APPLEII_MODEL
rts

View File

@ -0,0 +1,262 @@
; 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
.if 0
;========================
; 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:
; for this game with things in language card including
; irq handler, always force IIc mode (where RAM swapped in
; and we put the irq handler address directly up at $FFFE)
lda #<interrupt_handler
sta $fffe
lda #>interrupt_handler
sta $ffff
; nop out the "lda $45" since we are bypassing the ROM irq handler
; that puts A in $45
lda #$EA
sta interrupt_smc
sta interrupt_smc+1
;=========================
; 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
;=============================
; Disable Interrupt
;=============================
mockingboard_disable_interrupt:
sei ; disable interrupts just in case
lda #$40 ; Continuous interrupts, don't touch PB7
disable_irq_smc1:
sta MOCK_6522_ACR ; ACR register
lda #$7F ; clear all interrupt flags
disable_irq_smc2:
sta MOCK_6522_IER ; IER register (interrupt enable)
rts
.endif

View File

@ -0,0 +1,58 @@
;================================
;================================
;================================
;================================
scroll_screen:
ldx #8
stx INL
ldx #0
stx OUTL
scroll_yloop:
ldx INL
lda hposn_low,X
sta xloop_smc1+1
lda hposn_high,X
sta xloop_smc1+2
ldx OUTL
lda hposn_low,X
sta xloop_smc2+1
lda hposn_high,X
sta xloop_smc2+2
ldy #39
scroll_xloop:
xloop_smc1:
lda $2000,Y
xloop_smc2:
sta $2000,Y
dey
bpl scroll_xloop
inc INL
inc OUTL
lda INL
cmp #192
bne scroll_yloop
; blank bottom line
lda #$00
ldy #39
scroll_hline_xloop:
sta $23D0,Y
sta $27D0,Y
sta $2BD0,Y
sta $2FD0,Y
sta $33D0,Y
sta $37D0,Y
sta $3BD0,Y
sta $3FD0,Y
dey
bpl scroll_hline_xloop
rts

View File

@ -117,10 +117,13 @@ SOUND_STATUS = $8C
DISP_PAGE = $8D
DRAW_PAGE = $8E
TOTAL_RAM = $8F
;TIMER_COUNT = $86
;WHICH_SLOT = $88
NUM1L = $90
NUM1H = $91
NUM2L = $92
@ -175,6 +178,12 @@ INH = $FD
OUTL = $FE
OUTH = $FF
XSAVE = $F6
SCROLL_IN=$F7
SCROLL_OUT=$F8
STRING_COUNT = $F9
MEMCOUNT= $FA
LEAD0 = $FB