;This file resolves "init" and "author" as defined ;in sm.expansion.h. ;This code is compiled into a separate initialization ;module, so it is run once and then flushed from ;memory. Make sure that no data that is stored in ;this file is used during normal operation of SoftMMU. ;Remember that all source is #included together ;during compilation, so keep label names unique by ;including the expansion name in the label name. ;tsp_exp is defined, before #including this file, as ; the offset into the TSP where the expansion- ; specific bytes have been reserved. ;------ ;Readme ;------ ;Not a routine, just text. Include name, contact ;information, and release date, along with any other ;README-type stuff you wish to include. Since this ;isn't compiled into the kernel, don't worry about ;size considerations. readme_skeleton: .byte "Sample skeleton source code for " .byte "implementing a memory expansion " .byte "for SoftMMU. This code should not " .byte "be compiled!",$0a,$0a .byte "Released on October 27, 1999 by",$0a .byte "White Flame (aka David Holz)",$0a .byte "http://fly.to/theflame",$00 ;---- ;Init ;---- init_skeleton: ;There's 8 bytes of userzp allocated, but the 1st ;two bytes are used by sm_getfreelistpage (below). ;If you need more, specifically allocate it with ;set_zpsize. ;PRESERVE .X THROUGHOUT THIS ROUTINE. It holds ;the expansion number for the current module. ;1) Detect how much memory is present in the device. ; If it can't be detected or there is any error, ; return with carry set (and .X preserved). This ; will flag SoftMMU that the memory source is ; unavailable. ;2) To have SoftMMU automatically allocate memory ; for this device, set up a standard free list ; page. This routine uses also sets up a pointer ; to the free list page at userzp. jsr sm_getfreelistpage bcs + ;just in case. ;2a) If a free list page is set up, it must be ; initialized to contain at least 1 free list ; structure to tell SoftMMU that the memory ; is free to use. ldy #$00 ;Set up the structure lda #length sta (userzp),y iny lda #start sta (userzp),y iny tya ;Set up free list page info sta sm_top,x sta sm_open,x ;If a free list page is not used, SoftMMU will ;rely on the "xalloc" and "xfree" pointers set ;up in the sm.expansion.h file to allocate pages. ;Initialize anything that those routines need ;to run. + rts