Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- M_P3DOS equ $94 ; +3 DOS function call
- IDE_BANK equ $01bd ; NextZXOS function to manage memory
- ;;----------------------------------------------------------------------------------------------------------------------
- ;; Internal routine to allocate a single page from the OS.
- ;;
- ;; Output:
- ;; A = page # (or 0 if failed)
- ;;
- ;;----------------------------------------------------------------------------------------------------------------------
- allocPage: push ix
- push bc
- push de
- push hl
- ; Allocate a page by using the OS function IDE_BANK.
- ld hl,$0001 ; Select allocate function and allocate from normal memory.
- exx ; Function parameters are switched to alternative registers.
- ld de,IDE_BANK ; Choose the function.
- ld c,7 ; We want RAM 7 swapped in when we run this function (so that the OS can run).
- rst 8
- db M_P3DOS ; Call the function, new page # is in E
- jr c,.success
- ; We failed here
- xor a
- ld e,a ; Page # is 0 (i.e. error)
- .success ld a,e
- pop hl
- pop de
- pop bc
- pop ix
- ret
- ;;----------------------------------------------------------------------------------------------------------------------
- ;; Internal routine to return a previously allocated page back to the OS.
- ;;
- ;; Input:
- ;; A = page #
- ;;
- ;;----------------------------------------------------------------------------------------------------------------------
- freePage: push af
- push ix
- push bc
- push de
- push hl
- ld e,a ; E = page #
- ld hl,$0003 ; Deallocate function from normal memory
- exx ; Function parameters are switched to alternative registers.
- ld de,IDE_BANK ; Choose the function.
- ld c,7
- rst 8
- db M_P3DOS
- pop hl
- pop de
- pop bc
- pop ix
- pop af
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement