mirror of
https://github.com/simonowen/apple1emu.git
synced 2024-06-13 23:29:29 +00:00
- Changed to use $c000-dfff instead of $a000-bfff, saving 4K by overlapping I/O area. Decode table can be moved to a different 4K block if needed.
- Fixed Esc broken in 1.1 due to copy and paste bug - Removed unnecessary display paging
This commit is contained in:
parent
6d9b0f4f0d
commit
e712035197
|
@ -4,7 +4,7 @@
|
||||||
;
|
;
|
||||||
; WWW: http://simonowen.com/sam/apple1emu/
|
; WWW: http://simonowen.com/sam/apple1emu/
|
||||||
|
|
||||||
base: equ &a000 ; Spare-ish Apple 1 space
|
base: equ &d000 ; Emulator code shares Apple 1 I/O area
|
||||||
|
|
||||||
status: equ &f9 ; Status and extended keyboard port
|
status: equ &f9 ; Status and extended keyboard port
|
||||||
lmpr: equ &fa ; Low Memory Page Register
|
lmpr: equ &fa ; Low Memory Page Register
|
||||||
|
@ -25,10 +25,11 @@ m6502_nmi: equ &fffa ; nmi vector address
|
||||||
m6502_reset: equ &fffc ; reset vector address
|
m6502_reset: equ &fffc ; reset vector address
|
||||||
m6502_int: equ &fffe ; int vector address (also for BRK)
|
m6502_int: equ &fffe ; int vector address (also for BRK)
|
||||||
|
|
||||||
|
r1onclbc: equ &01ea ; ROM 1 on, call BC
|
||||||
getkey: equ &1cab ; SAM ROM key reading (NZ=got key in A, A=0 for no key)
|
getkey: equ &1cab ; SAM ROM key reading (NZ=got key in A, A=0 for no key)
|
||||||
|
|
||||||
|
|
||||||
; Apple 1 keyboard and display I/O locations
|
; PIA registers for keyboard and display I/O
|
||||||
|
|
||||||
kbd_data: equ &d010 ; keyboard data
|
kbd_data: equ &d010 ; keyboard data
|
||||||
kbd_ctrl: equ &d011 ; keyboard control
|
kbd_ctrl: equ &d011 ; keyboard control
|
||||||
|
@ -41,17 +42,26 @@ dsp_ctrl: equ &d013 ; display control
|
||||||
dump $
|
dump $
|
||||||
autoexec
|
autoexec
|
||||||
|
|
||||||
start: di
|
di
|
||||||
|
jr start
|
||||||
|
|
||||||
ld a,low_page+rom0_off
|
defs kbd_data-$
|
||||||
|
; This gap contains the PIA locations from above
|
||||||
|
defs dsp_ctrl-kbd_data+1
|
||||||
|
|
||||||
|
start: ld a,low_page+rom0_off
|
||||||
out (lmpr),a
|
out (lmpr),a
|
||||||
ld a,vmpr_mode2+screen_page
|
ld a,vmpr_mode2+screen_page
|
||||||
out (vmpr),a
|
out (vmpr),a
|
||||||
|
ld (basic_stack),sp
|
||||||
ld sp,stack_top
|
ld sp,stack_top
|
||||||
|
|
||||||
call set_sam_attrs ; set the mode 2 attrs so the screen is visible
|
call set_sam_attrs ; set the mode 2 attrs so the screen is visible
|
||||||
call setup_im2 ; enable IM 2
|
call setup_im2 ; enable IM 2
|
||||||
|
|
||||||
|
ld a,(op_00) ; lowest address used by emulator
|
||||||
|
ld (rom_write+1),a ; save byte to restore to simulate ROM
|
||||||
|
|
||||||
reset_loop: ld hl,0
|
reset_loop: ld hl,0
|
||||||
ld (dsp_data),hl ; display ready
|
ld (dsp_data),hl ; display ready
|
||||||
ld (kbd_data),hl ; no key available
|
ld (kbd_data),hl ; no key available
|
||||||
|
@ -243,10 +253,6 @@ file_skip: ld a,(hl) ; fetch next file character
|
||||||
jr nz,file_done
|
jr nz,file_done
|
||||||
ld a,&0d ; convert LF to CR
|
ld a,&0d ; convert LF to CR
|
||||||
file_done: ld (filepos),hl
|
file_done: ld (filepos),hl
|
||||||
ex af,af'
|
|
||||||
ld a,screen_page+rom0_off
|
|
||||||
out (lmpr),a
|
|
||||||
ex af,af'
|
|
||||||
and a
|
and a
|
||||||
ret
|
ret
|
||||||
filepos: defw 0
|
filepos: defw 0
|
||||||
|
@ -282,7 +288,6 @@ update_io:
|
||||||
ld a,&c9 ; RET opcode
|
ld a,&c9 ; RET opcode
|
||||||
ld (main_loop),a ; return to reset on next instruction
|
ld (main_loop),a ; return to reset on next instruction
|
||||||
not_reset:
|
not_reset:
|
||||||
jr c,got_key ; unshifted gives chr
|
|
||||||
|
|
||||||
still_esc: ld a,&f7
|
still_esc: ld a,&f7
|
||||||
in a,(status)
|
in a,(status)
|
||||||
|
@ -315,13 +320,13 @@ not_sym:
|
||||||
call get_filekey ; got a type-in key from file?
|
call get_filekey ; got a type-in key from file?
|
||||||
jr nz,got_key ; jump if we have
|
jr nz,got_key ; jump if we have
|
||||||
|
|
||||||
skip_key: ld a,&1f+rom1_on
|
skip_key: ld a,&1f ; LMPR page for BASIC, with ROM 0 enabled
|
||||||
out (lmpr),a
|
out (lmpr),a
|
||||||
call getkey
|
ld (save_stack),sp
|
||||||
ex af,af'
|
ld sp,(basic_stack)
|
||||||
ld a,screen_page+rom0_off
|
ld bc,getkey ; return key code in A, zero for none
|
||||||
out (lmpr),a
|
call r1onclbc
|
||||||
ex af,af'
|
ld sp,(save_stack)
|
||||||
jr z,no_key
|
jr z,no_key
|
||||||
call map_key
|
call map_key
|
||||||
and a
|
and a
|
||||||
|
@ -343,6 +348,8 @@ no_key:
|
||||||
cp &7f
|
cp &7f
|
||||||
jr z,done_draw
|
jr z,done_draw
|
||||||
push af
|
push af
|
||||||
|
ld a,screen_page+rom0_off
|
||||||
|
out (lmpr),a ; page in screen
|
||||||
ld a,&00 ; space
|
ld a,&00 ; space
|
||||||
call display_chr ; erase cursor
|
call display_chr ; erase cursor
|
||||||
pop af
|
pop af
|
||||||
|
@ -392,11 +399,7 @@ im2_handler: push af
|
||||||
|
|
||||||
in a,(lmpr)
|
in a,(lmpr)
|
||||||
push af
|
push af
|
||||||
ld a,screen_page+rom0_off
|
|
||||||
out (lmpr),a
|
|
||||||
|
|
||||||
call update_io
|
call update_io
|
||||||
|
|
||||||
pop af
|
pop af
|
||||||
out (lmpr),a
|
out (lmpr),a
|
||||||
|
|
||||||
|
@ -425,6 +428,9 @@ im2_table: defs 257
|
||||||
stack_top: ; stack fits nicely in the slack space
|
stack_top: ; stack fits nicely in the slack space
|
||||||
im2_jp: jp im2_handler
|
im2_jp: jp im2_handler
|
||||||
|
|
||||||
|
basic_stack: defw 0
|
||||||
|
save_stack: defw 0
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
@ -442,7 +448,7 @@ i_undoc_1: jp (ix) ; NOP
|
||||||
|
|
||||||
read_write_loop:
|
read_write_loop:
|
||||||
write_loop: ld a,h
|
write_loop: ld a,h
|
||||||
cp base/256 ; emulator or ROMs above?
|
cp op_00/256 ; MSB of lowest emulator byte
|
||||||
jr nc,write_trap
|
jr nc,write_trap
|
||||||
|
|
||||||
zwrite_loop:
|
zwrite_loop:
|
||||||
|
@ -454,8 +460,8 @@ main_loop: ld a,(de) ; 7/7/15 - fetch opcode
|
||||||
jp (hl) ; 4/5/9 - execute!
|
jp (hl) ; 4/5/9 - execute!
|
||||||
; = 35T (official) / 40T (off-screen) / 72T (on-screen)
|
; = 35T (official) / 40T (off-screen) / 72T (on-screen)
|
||||||
|
|
||||||
write_trap: cp &d0
|
write_trap: cp &d0 ; I/O page?
|
||||||
jr nz,write_rom
|
jr nz,rom_write
|
||||||
ld a,l
|
ld a,l
|
||||||
cp &12 ; display char?
|
cp &12 ; display char?
|
||||||
jr z,chr_write
|
jr z,chr_write
|
||||||
|
@ -463,8 +469,8 @@ write_trap: cp &d0
|
||||||
chr_write: set 7,(hl) ; display busy
|
chr_write: set 7,(hl) ; display busy
|
||||||
jp (ix)
|
jp (ix)
|
||||||
|
|
||||||
write_rom: ld a,&f3 ; Z80 DI opcode
|
rom_write: ld a,&00 ; patched by starting code
|
||||||
ld (base),a ; emulator appears to be in ROM for RAM tests
|
ld (op_00),a ; emulator appears read-only to be ROM for RAM tests
|
||||||
jp (ix)
|
jp (ix)
|
||||||
|
|
||||||
read_loop: ld a,h
|
read_loop: ld a,h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user