Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !zone Main
- !to "disk_32e5370fc2358b90.img"
- *=0x500
- JMP Main
- !zone Init {
- Init SEC
- XCE
- REP #$30 ; 16-bit mode
- !al
- LDA #$1
- MMU #$0 ; map device 1 to redbus window
- LDA #$300
- MMU #$1 ; redbus window situated at 0x300
- MMU #$2 ; enable redbus
- LDA #$400
- MMU #$3 ; external memory situated at 0x400
- MMU #$4 ; enable external memory
- LDA #$500
- MMU #$6 ; POR = 0x500, whatever that might be
- LDA #0
- JSR Output ; Clear IO Expander
- RTS
- }
- !zone Output {
- Output PHA ; Only works in 16-bit mode!
- LDA #$3
- MMU #$0
- PLA
- STA $302
- PHA
- LDA #$1
- MMU #$0
- PLA
- RTS
- }
- !zone {
- Main JSR Init ; Initial stuff
- LDA #0
- STA $303 ; Hide cursor
- SEP #$30 ; 8-bit
- !as
- LDA Text
- STA $310 ; Display saved character
- REP #$30 ; 16-bit
- !al
- - WAI
- LDA #1
- MMU #0 ; Monitor
- LDA $305 ; Amount of keys
- AND #$FF ; We are in 16 bit mode and we only need one byte. Let's Mask it.
- CMP #0
- BEQ - ; If there are no key presses, jump back
- DEC
- STA $304 ; Read last key
- LDA $306 ; A = Pressed key
- JSR Output ; Output the pressed key
- SEP #$30
- !as
- STA $310 ; Display pressed key
- REP #$30
- !al
- TAY ; Save the pressed key in Y
- LDA #0
- STA $305 ; Reset amount of keys
- LDA #2
- MMU #0 ; Disk drive
- LDA #128
- STA $D
- LDA #Text
- SBC #$500
- DIV $D ; (Text-0x500)/128 =
- STA $380 ; Disk Sector
- SEP #$30 ; 8-bit
- !as
- LDA #4
- STA $382 ; Read sector content
- -- WAI ; Wait for ready
- LDA $382
- CMP #$FF
- BEQ .Fault ; Something bad happened. Let's signal the user and panic
- CMP #0
- BNE -- ; Not ready yet, try again
- TDA ; A = remainder of last division
- TAX ; X = remainder of last division
- TYA ; A = The key
- STA $300, X ; Save the key into the disk buffer
- LDA #5
- STA $382 ; Issue write command to disk drive
- -- WAI ; Wait for ready
- LDA $382
- CMP #$FF
- BEQ .Fault ; Something bad happened
- CMP #0
- BNE -- ; Not read yet
- STP ; Repeating doesn't work for some reason, so let's stop here
- ;REP #$30 ; 16-bit
- ;!al
- ;JMP -
- .Fault REP #$30
- !al
- LDA #$FFFF
- JSR Output
- STP
- }
- !zone Data {
- Text !8 0x20
- !align 128, 0, 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement