; ; gui.s ; Top level management routines ; ; Created by Quinn Dunki on 8/15/14. ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. ; .org $7a00 ; Common definitions .include "zeropage.s" .include "switches.s" .include "macros.s" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Main entry point. BRUN will land here. main: jsr WGInit ; Copy ourselves into AUX Memory ; lda #
main sta A1H lda #WG_END sta A2H lda #
main sta A4H sec jsr AUXMOVE tsx ; Firmware convention requires saving the stack pointer before any XFERs stx $0100 ldx #$ff stx $0101 rts ; This is the non-negotiable entry point used by applications Don't move it! WeeGUI = $300 WeeGUIMouse = $9344 WGDISPATCH = WeeGUI + (WGEntryPointTable-WGDispatch) WGDISPATCHRETURN = WeeGUI + (WGDispatchMAIN-WGDispatch) WGCALLBACKRETURN = WeeGUI + (WGCallbackReturn-WGDispatch) WGFirstMouseDispatch = 62 ; Special cases for the dispatcher above this value WGEnableMouseDispatch = 62 WGDisableMouseDispatch = 64 WGPointerDirtyDispatch = 66 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGDispatch ; The dispatcher for calling the assembly-language API from assembly programs. ; This routine gets copied into $300 for use by main bank programs and Applesoft ; X: API call number ; P0-3,Y: Parameters to call, as needed ; WGDispatch: ; Check some special cases cpx #WGFirstMouseDispatch bcs WGDispatch_mouse lda WGDISPATCH,x ; Set up to transfer control into AUX memory sta XFERL lda WGDISPATCH+1,x sta XFERH tsx ; Firmware convention requires saving the stack pointer before XFER stx $0100 lda #>WGDispatchReturn ; Give our routine somewhere to come back to pha lda #WGCallbackAUX sta XFERH sec ; Transfer control to the routine in AUX memory clv jmp XFER ; This is the end of what is copied into $300 in MAIN memory WGDispatchEnd: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGDispatchReturn ; This is an anchor point in AUX memory that WeeGUI subroutines ; RTS back to. From here, we transfer control safely back to main ; memory so the caller can resume. ; WGDispatchReturn: nop ; Needed because RTS will skip one instruction, per usual lda #WGDISPATCHRETURN sta XFERH clc ; Transfer control to the routine in MAIN memory clv jmp XFER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGCallback ; Calls a user's routine in MAIN memory ; XFERL: Pointer in main memory (LSB) ; XFERH: Pointer in main memory (MSB) WGCallback: lda #>WGCALLBACKRETURN ; Give user's routine somewhere to come back to pha lda #