#define georam_page $dffe ;select a page within the bank #define georam_bank $dfff ;select a 16k bank #define georam_window $de00 ;256-byte window into expansion memory #define georam_maxpage $3f ;there are 64 256-byte pages within each 16k bank #define georam_maxbank userzp+2 ;detected size of the unit #define georam_temp userzp+3 ;------ ;Readme ;------ readme_georam: .byte "GeoRAM/BBGRam SoftMMU module.",$0a,$0a .byte "Supports up to 4 megs in a single " .byte "expansion.",$0a,$0a .byte "October 27, 1999",$0a .byte "White Flame (aka David Holz)",$0a .byte "http://fly.to/theflame",$00 ;---- ;Init ;---- init_georam: ;Find out how many bits the bank select register supports ldy #$00 tya sta georam_page - sty georam_bank ;first, clear the first byte of each bank sta georam_window iny bne - clc ;clear carry for shift operations lda #$01 - sta georam_bank ;save a number sta georam_window ldy #$00 sty georam_bank ;see if bank 0 got changed because of it ldy georam_window bne + asl a ;bump up another bit bcc - ;all the way up to 4 megs (why not?) + sbc #$01 sta georam_maxbank beq + ;if nothing detected, exit with carry set ;Allocate a page for the free memory list jsr sm_getfreelistpage bcs + ;Now, set up the free memory list lda #$ff ;calculate # of pages from maxbank sta georam_temp lda georam_maxbank lsr a ror georam_temp lsr a ror georam_temp ldy #$01 sta (userzp),y ;save >length dey lda georam_temp sta (userzp),y ;save start ;Finally, set internal pointers for top of free list and next ;open list location lda #$04 sta sm_top,x sta sm_open,x + rts