; simple example that demonstrates the "autoselect" command ptr = $02 res00 = $f8 res01 = $f9 res02 = $fa * = $0801 !byte $0c, $08, $00, $00, $9e, $20, $34, $30, $39, $36 !byte 0,0,0 * = $1000 sei ; clear screen ldx #0 - lda #$20 sta $0400,x sta $0500,x sta $0600,x sta $0700,x lda #$01 sta $d800,x sta $d900,x sta $da00,x sta $db00,x inx bne - ; print header ldx #0 - lda header,x sta $0400,x inx cpx #4*40 bne - ; get the status for each bank lda #$03 sta $de00 ; enable the cartridge ROM ldx #0 - jsr cmd_autoselect lda res00 sta $0400+(22*40),x lda res01 sta $0400+(23*40),x lda res02 sta $0400+(24*40),x inx cpx #8*2 bne - ; print the status bytes as hex lda #>($0400+(4*40)) sta ptr+1 lda #<($0400+(4*40)) sta ptr ldx #0 - txa pha ldy #0 lda $0400+(22*40),x jsr hexout lda $0400+(23*40),x jsr hexout lda $0400+(24*40),x jsr hexout lda ptr clc adc #40 sta ptr bcc + inc ptr+1 + pla tax inx cpx #8*2 bne - ; wait forever jmp * hexout: pha lsr lsr lsr lsr tax lda hextab,x sta (ptr),y iny pla and #$0f tax lda hextab,x sta (ptr),y iny iny rts hextab: !scr "0123456789abcdef" bankbits: !byte (0 << 5) or (0 << 7) or (0 << 4) or (0 << 3) !byte (0 << 5) or (0 << 7) or (0 << 4) or (1 << 3) !byte (0 << 5) or (0 << 7) or (1 << 4) or (0 << 3) !byte (0 << 5) or (0 << 7) or (1 << 4) or (1 << 3) !byte (0 << 5) or (1 << 7) or (0 << 4) or (0 << 3) !byte (0 << 5) or (1 << 7) or (0 << 4) or (1 << 3) !byte (0 << 5) or (1 << 7) or (1 << 4) or (0 << 3) !byte (0 << 5) or (1 << 7) or (1 << 4) or (1 << 3) !byte (1 << 5) or (0 << 7) or (0 << 4) or (0 << 3) !byte (1 << 5) or (0 << 7) or (0 << 4) or (1 << 3) !byte (1 << 5) or (0 << 7) or (1 << 4) or (0 << 3) !byte (1 << 5) or (0 << 7) or (1 << 4) or (1 << 3) !byte (1 << 5) or (1 << 7) or (0 << 4) or (0 << 3) !byte (1 << 5) or (1 << 7) or (0 << 4) or (1 << 3) !byte (1 << 5) or (1 << 7) or (1 << 4) or (0 << 3) !byte (1 << 5) or (1 << 7) or (1 << 4) or (1 << 3) header: ;0123456789012345678901234567890123456789 !scr "/-------- manufacturer id (01 = amd) " !scr "! /----- device id (20 = 29f010) " !scr "! ! /-- protection status (01 = on) " !scr "! ! ! " ;------------------------------------------------------------------------------- cmd_autoselect: LDA #$10 STA $de01 ;set bank LDA #$aa STA $9555 ;this is a write to $5555 of the chip LDA #$08 STA $de01 ;set bank LDA #$55 STA $8aaa ;this is a write to $2aaa of the chip LDA #$10 STA $de01 ;set bank LDA #$90 STA $9555 ;write $90 to $5555 lda bankbits, x STA $de01 ;set bank you wish to read status from LDA $8000 ;read manufacturer code ($01 for AMD) sta res00 LDA $8001 ;read device code ($20 for 29F010) sta res01 LDA $8002 ;read sector protect information in bit 0. 1=sector protected sta res02 rts