;--------------------------------------------------------------------------- ; simple example that demonstrates how to write to the flash ROM ; ; this test programs first page of each 8k bank and writes a single value ; that represents the bank number to the first (low byte) and second (high byte) ; bank ;--------------------------------------------------------------------------- !src "../include/gmod3.inc" * = $0801 !word nextline !word 2016 !byte $9e !byte $32, $30, $36, $31 nextline: !byte 0,0,0 jmp start !src "../lib/gmod3.asm" NOHIGHBYTE = 0 ;------------------------------------------------------------------------------- start: ;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 - ldy #0 -- tya pha !if NOHIGHBYTE = 0 { sta cart_file_start+1 } ldx #0 - txa pha sta cart_file_start inc $0420 ; to indicate progress ; erase 64k page if needed lda pagelo bne + ; only erase when lobyte is 0, ie every 64k lda pagehi jsr flash_erase + inc $0421 ; to indicate progress ; set byte program command and flash address pagehi=*+1 lda #0 sta addr2 pagelo=*+1 lda #0 sta addr1 ;lda #0 ;sta addr0 inc $0422 ; to indicate progress lda #cart_file_start ; program one 256byte page jsr flash_writepage lda cart_file_start pha lsr lsr lsr lsr tay lda hexdigits,y sta $0400 pla and #$0f tay lda hexdigits,y sta $0401 lda cart_file_start+1 pha lsr lsr lsr lsr tay lda hexdigits,y sta $0402 pla and #$0f tay lda hexdigits,y sta $0403 lda pagehi pha lsr lsr lsr lsr tay lda hexdigits,y sta $0405 pla and #$0f tay lda hexdigits,y sta $0406 lda pagelo pha lsr lsr lsr lsr tay lda hexdigits,y sta $0407 pla and #$0f tay lda hexdigits,y sta $0408 lda pagelo clc adc #$20 sta pagelo bcc + inc pagehi + pla tax inx beq + jmp - + pla tay iny cpy #$08 beq + jmp -- + - inc $d020 dec $d020 jmp - failure: lda #2 sta $d020 jmp * hexdigits: !scr "0123456789abcdef" ;------------------------------------------------------------------------------- ; align to page boundary so we only have to compare the highbyte of the ; source address in the above loop !align 255,0 cart_file_start: !for i,0,255 { !byte $ff }