Files
Shawn Quick dfcaae62dd Add qlink, the disk tools, and a bootable ProDOS 8 image.
Move the assembler to src/qasm. qlink links OMF 1.0 and 2.0 from a script. makeBin flattens a load file, qomf dumps OMF, and qpro builds ProDOS volumes. APW and MPW assemble through the ORCA front end. Relocatable modules emit OMF objects. Listings stay off unless -l is set.

make boot assembles the GS/OS 6.0.1 ProDOS 8 kernel and BASIC.SYSTEM into an 800K volume. BASIC.SYSTEM accepts ls and pfx, and its splash reports PRODOS BASIC 2.0, copyright 1983-2026. IIGS.601.SRC is the source and the BASIC.SYSTEM oracle that image is built from.
2026-10-16 14:41:55 -07:00

1 line
22 KiB
NASM
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
title 'ROMDataMgr'
**********************************************************************
*
* ROMDataMgr
* Copyright (C) 1989
* Apple Computer, Inc.
* All Rights Reserved
*
* This file contains the routines
*
* GetROMResource
* ReleaseROMResource
*
*
* These routines will allow ROM code to take advantage of resources when
* they are available by checking to see if a resource exists and loading it
* for the tool if needed. If the resource is not needed, this routine will
* simply return a fake handle to a ROM resource.
*
* Version 1.0 Mensch
* 1/16/89 Initial version
*
* 2/17/89 Yee
* Changed size of bounds rect for the edit line control.
* Did not allow enough room for 3 chars. X2 changed from
* 241 to 247. BRC #41036
*
* 2/23/89 Mensch
* Changed keytrans table to fix bugs reported in
* BRC #44583
*
* 22-Apr-91 Dave Lyons
*
* Minor changes to the ChooseFont resources to make it look pretty how
* Ron wants it.
*
**********************************************************************
include 'all.macros'
include 'mt.equates.asm'
include '::sys.equs.asm'
EJECT
*******************************************************************************
*
ROMDataArea RECORD
import w320start
import w640start
*
* Description: This area contains ROM resources that are used by ALL tools
* feel free to add to this list any time you want, HOWEVER
* try not to remove any data without making sure no one else
* is using it! The format of each "Resource" is:
*
* theType - WORD type of resource (must match res mgr types
* theID - LONG Unique 4 byte integer for this type of resource
* thePtr - LONG pointer to the raw data
*
* the table MUST terminate with an entry filled with blanks
* following the table, you can define any data you want. All
* ROM data should be in here.
*
* ID Conventions. It would be nice if we all followed simple
* guidelines for creating ID numbers for our resources.
* the ID should be in the following format
*
* $0FFFttii
* where tt is the tool set number and ii is a unique
* id number for that toolset.
*
*******************************************************************************
SizeofEntry equ 10
TypeList dc.W $FFFF ; first resource is a sample...
IDList dc.L 1 ; please don't remove...
HandleTbl dc.L HandleTbl ; sampleData
; Entry for Font Manager ChooseFont templates here!
dc.W $800E ; resource Type
dc.L $0FFF1B01 ; font manager window #1
dc.L w320Start
dc.W $800E ; res type
dc.L $0FFF1B02 ; font manager window #2
dc.L w640Start
IF Big=1 THEN
; Entry for Event manager
; Default ID is now $FF instead of $01
dc.W $8021 ; res Type Ktrans table
dc.L $0FFF06FF ; ID Number
dc.L DefkTransTbl ; default ktrans table
ENDIF
;
; END OF ID TABLE: DO NOT MODIFY THIS NEXT RECORD
dc.W $0000
dc.L $00000000
dc.L $00000000
;
; Event Manager data area
MACRO
dosomeBytes &Start,&End
LCLA &counter
&Counter SETA &Start ; init our counter
WHILE (&Counter<(&End+1)) DO
dc.B &Counter
&Counter: SETA &Counter+1
ENDWHILE
ENDM
IF Big=1 THEN
DefkTransTbl
dosomeBytes 0,127 ; generate normal keys, no sub
; option substitution table starts here...
; NOTE that when a printable mac keystroke exists for this table,
; we will use the same keystroke that the mac uses
doSomeBytes 0,31 ; generate option control, no change
;
; the following table generated by:
;set x 32
;Loop
; echo "¶tdc.B ${x}¶t;sub for option - {x}" ;
; set x `evaluate {x}+1` ;
; If {X}>127
; break
; else
; continue
; end;
;End
dc.B $CA ;sub for option - 32
dc.B $DA ;sub for option - 33
dc.B $AE ;sub for option - 34
dc.B $DC ;sub for option - 35
dc.B $DD ;sub for option - 36
dc.B $DE ;sub for option - 37
dc.B $E0 ;sub for option - 38
dc.B $BE ;sub for option - $27
dc.B $E1 ;sub for option - 40
dc.B $E2 ;sub for option - 41
dc.B $A1 ;sub for option - 42
dc.B $B1 ;sub for option - +
dc.B $B2 ;sub for option - ,
dc.B $D0 ;sub for option - -
dc.B $B3 ;sub for option - .
dc.B 'Ö' ;sub for option - /
dc.B $BC ;sub for option - $30
dc.B $C1 ;sub for option - 49
dc.B $AA ;sub for option - 50
dc.B $A3 ;sub for option - 51
dc.B $A2 ;sub for option - 52
dc.B $B0 ;sub for option - 53
dc.B $A4 ;sub for option - 54
dc.B $A6 ;sub for option - 55
dc.B $A5 ;sub for option - 56
dc.B $BB ;sub for option - 57
dc.B $F2 ;sub for option - 58
dc.B $C9 ;sub for option - 59
dc.B $F8 ;sub for option - 60
dc.B $AD ;sub for option - 61
dc.B $F9 ;sub for option - 62
dc.B $C0 ;sub for option - 63
dc.B $DB ;sub for option - $40
dc.B $81 ;sub for option - 65
dc.B $F5 ;sub for option - 66
dc.B $82 ;sub for option - 67
dc.B $EB ;sub for option - 68
dc.B $E4 ;sub for option - 69
dc.B $EC ;sub for option - 70
dc.B $ED ;sub for option - 71
dc.B $EE ;sub for option - 72
dc.B $E9 ;sub for option - 73
dc.B $EF ;sub for option - J
dc.B $F0 ;sub for option - K
dc.B $F1 ;sub for option - L
dc.B $F7 ;sub for option - M
dc.B $F6 ;sub for option - N
dc.B $AF ;sub for option - O
dc.B $B8 ;sub for option - P
dc.B $CE ;sub for option - Q
dc.B $E5 ;sub for option - R
dc.B $EA ;sub for option - S
dc.B $E6 ;sub for option - T
dc.B $E8 ;sub for option - U
dc.B $D7 ;sub for option - V
dc.B $E3 ;sub for option - W
dc.B $F4 ;sub for option - X
dc.B $E7 ;sub for option - Y
dc.B $F3 ;sub for option - Z
dc.B $D2 ;sub for option - [
dc.B $C7 ;sub for option - \
dc.B $D4 ;sub for option - ]
dc.B $DF ;sub for option - 94
dc.B $D1 ;sub for option - 95
dc.B $60 ;sub for option - $60
dc.B $8C ;sub for option - a
dc.B $BA ;sub for option - b
dc.B $8D ;sub for option - c
dc.B $B6 ;sub for option - d
dc.B $AB ;sub for option - e
dc.B $C4 ;sub for option - f
dc.B $A9 ;sub for option - g
dc.B $FA ;sub for option - h
dc.B $5E ;sub for option - i
dc.B $C6 ;sub for option - j
dc.B $FB ;sub for option - k
dc.B $C2 ;sub for option - l
dc.B $B5 ;sub for option - m
dc.B $7E ;sub for option - n
dc.B $BF ;sub for option - o
dc.B $B9 ;sub for option - p
dc.B $CF ;sub for option - q
dc.B $A8 ;sub for option - r
dc.B $A7 ;sub for option - s
dc.B $A0 ;sub for option - t
dc.B $AC ;sub for option - u
dc.B $C3 ;sub for option - v
dc.B $B7 ;sub for option - w
dc.B $C5 ;sub for option - x
dc.B $B4 ;sub for option - y
dc.B $BD ;sub for option - z
dc.B $D3 ;sub for option - {
dc.B $C8 ;sub for option - |
dc.B $D5 ;sub for option - }
dc.B $D9 ;sub for option - ~
dc.B $7F ;sub for option - DEL
; end Sub_Array here, now create the dead key table...
DeadKStart
; First, entry for grave accent
dc.B $60,(GAStart-DeadKStart)/2
; next carat over letter...
dc.B $5E,(CAStart-DeadKStart)/2
; accent over letter
dc.B $AB,(ACStart-DeadKStart)/2
; TidlŽ over letter
dc.B $7E,(TCStart-DeadKStart)/2
; oomlaut over letter
dc.B $AC,(OLStart-DeadKStart)/2
; end of this table
dc.W 0
GAStart
dc.B 'a','ˆ'
dc.B 'A','Ë'
dc.B 'e','�'
dc.B 'i','“'
dc.B 'o','˜'
dc.B 'u','�'
dc.B ' ','`'
dc.W $0000
CAStart
dc.B 'a','‰'
dc.B 'e','�'
dc.B 'i','”'
dc.B 'o','™'
dc.B 'u','ž'
dc.B ' ','^'
dc.W $0000
ACStart
dc.B 'E','ƒ'
dc.B 'a','‡'
dc.B 'e','Ž'
dc.B 'i','’'
dc.B 'o','—'
dc.B 'u','œ'
dc.B ' ','«'
dc.W $0000
TCStart
dc.B 'A','Ì'
dc.B 'N','„'
dc.B 'O','Í'
dc.B 'a','‹'
dc.B 'n','–'
dc.B 'o','›'
dc.W $0000
OLStart
dc.B 'A','€'
dc.B 'O','…'
dc.B 'U','†'
dc.B 'a','Š'
dc.B 'e','‘'
dc.B 'i','•'
dc.B 'o','š'
dc.B 'u','Ÿ'
dc.B 'y','Ø'
dc.B ' ','¬'
dc.W $0000
; end ktrans table here
ENDIF
EndR
ChooseFontStuff proc export
export w320start
export w640start
*-------------- Window Stuff for ChooseFont --------------------
; Equates for ChooseFont item ID's
MDListID equ 1
SizeListID equ 2
SizeEditID equ 3
OKID equ 4
CancelID equ 5
; these next style ID's must be in order...
PlainSID equ 6
BoldSID equ 7
ItalicSID equ 8
UnderSID equ 9
OutlineSID equ 10
ShadowSID equ 11
LastSID equ 12
;
stat1ID equ 12
stat2ID equ 13
stat3ID equ 14
styleFrameID equ $42
;
; RefCon Equates for ChooseFont controls
useNILHit equ 0
useFontHit equ 1
useSizeHit equ 2
useOtherHit equ 3
useOKHit equ 4
useCancelHit equ 5
usePlainHit equ 6
useStyleHit equ 7
W320Start
DC.W W320_End-W320Start ;$50 ;wind_end-wind_size
DC.W %0010000000000001 ;made invisible 17-Feb-91 DAL
DC.L 0
DC.L 0
DC.W 0,0,0,0
DC.L 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0 ;Number of pixels to scroll vertically.
DC.W 0 ;Number of pixels to scroll horizontally.
DC.W 0 ;Number of pixels to page vertically.
DC.W 0 ;Number of pixels to page horizontally.
DC.L 0 ;Infomation bar text string.
DC.W 0 ;Height of information bar.
DC.L 0 ;DefProc.
DC.L 0 ;Routine to draw info. bar.
DC.L 0 ;Routine to draw content.
dc.W 25,20,185,300 ;window position
DC.L $FFFFFFFF ;Plane to put window up in.
DC.L w320CtlLst ;Address of array of control pointers.
dc.W 3 ; control template list of ptrs...
w320_end
w320CtlLst
;;; dc.L w640MDList,w640SizeList,w640SizeEdit,w320OKButton
dc.L w640SizeEdit,w640SizeList,w320MDList,w320OKButton
dc.L w320CanButton,w640plainS,w640BoldS,w640ItalicS
dc.L w640UnderS,w640OutLineS,w640ShadowS,w640Stat1
dc.L w640Stat2,w640Stat3,w320StyleFrame
dc.L 0
W640Start
DC.W W640_End-W640Start ;$50 ;wind_end-wind_size
DC.W %0010000000000001 ;made invisible 17-Feb-91 DAL
DC.L 0
DC.L 0
DC.W 0,0,0,0
DC.L 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0
DC.W 0 ;Number of pixels to scroll vertically.
DC.W 0 ;Number of pixels to scroll horizontally.
DC.W 0 ;Number of pixels to page vertically.
DC.W 0 ;Number of pixels to page horizontally.
DC.L 0 ;Infomation bar text string.
DC.W 0 ;Height of information bar.
DC.L 0 ;DefProc.
DC.L 0 ;Routine to draw info. bar.
DC.L 0 ;Routine to draw content.
dc.W 25,175,185,465 ;window position
DC.L $FFFFFFFF ;Plane to put window up in.
DC.L w640CtlLst ;Address of array of control pointers.
dc.W 3 ; control template list of ptrs...
w640_end
w640CtlLst
;;; dc.L w640MDList,w640SizeList,w640SizeEdit,w640OKButton
dc.L w640SizeEdit,w640SizeList,w640MDList,w640OKButton
dc.L w640CanButton,w640plainS,w640BoldS,w640ItalicS
dc.L w640UnderS,w640OutLineS,w640ShadowS,w640Stat1
dc.L w640Stat2,w640Stat3,w640StyleFrame
dc.L 0
w640MDList dc.W 8 ; number of parameters
dc.L MDListID ; app ID
*** dc.W 14,15,76,250 ; font rectangle
dc.W 14-1,15+2-9,76-1,250+2+18+9 ; font-list rectangle
dc.L $89000000 ; procref
dc.W 0 ; flags (visible)
dc.W $7000 ; MoreFlags (FctlProcNotPtr) [was $1000 4-Feb-91 DAL; can be target now]
DC.L useFontHit ;refcon
dc.W 0 ; number of members
DC.W 0 ;view size
DC.W 2+4 ;type of members
DC.W 1 ;starting member
DC.L 0 ;List drawing routine
DC.W 10 ;height of member in pixels
DC.W 8 ;size of each member record
DC.L 0 ;pointer to member list
dc.L 0
w320MDList dc.W 8 ; number of parameters
dc.L MDListID ; app ID
*** dc.W 14,15,76,250 ; font rectangle
dc.W 14-1,15+2-9,76-1,250+2+18+9-8 ; font-list rectangle
dc.L $89000000 ; procref
dc.W 0 ; flags (visible)
dc.W $7000 ; MoreFlags (FctlProcNotPtr) [was $1000 4-Feb-91 DAL; can be target now]
DC.L useFontHit ;refcon
dc.W 0 ; number of members
DC.W 0 ;view size
DC.W 2+4 ;type of members
DC.W 1 ;starting member
DC.L 0 ;List drawing routine
DC.W 10 ;height of member in pixels
DC.W 8 ;size of each member record
DC.L 0 ;pointer to member list
dc.L 0
w640SizeList dc.W 14
dc.L SizeListID
*** dc.w 90,130,152,173
dc.w 90-7,128,152+4,171 ;new rectangle 4 pixels to the left, since it can be the Target now (17-Feb-91 DAL)
dc.L $89000000
dc.W 0
dc.W $7000 ;moreflags was $1000 4-Feb-91 DAL (can be target now)
dc.L useSizeHit ;refcon
dc.W 0 ;listsize
dc.W 0 ;listView
dc.W 2 ;listType
dc.W 1 ;listStart
dc.L 0 ;listDraw (should be patched later when list created)
dc.W 10 ;listMemHeight
dc.W 5 ;listMemSize
dc.L 0 ;listRef set by newList2...
;;; dc.L 0 ;colorTableRef
w640SizeEdit dc.W 8 ; size of the record
dc.L SizeEditID ; app ID
*** dc.W 101,211,112,247
dc.w 100-8,211,113-8,247 ;new rectangle 17-Feb-91 DAL (taller)
dc.L $83000000
dc.W 0 ; flags (visible)
dc.W $1000 ; procnotref default is ptr
dc.L useOtherHit ; refcon
dc.W 3 ; max string length
dc.L 0 ; no default...
w640OKButton dc.W 9 ; size of the record
dc.L OKId ; appID
*** dc.W 140,205,153,275
dc.W 140+1,207,153+1,277
dc.L $80000000
dc.W 1
dc.W $3000
dc.L useOKHit
dc.L OKStr
dc.l 0 ;color table
dc.b $0d,$0d ;Return
dc.w 0,0 ;modifiers
w640CanButton dc.W 9
dc.L CancelID
*** dc.W 122,205,135,275
dc.W 122+1,207,135+1,277
dc.L $80000000
dc.W 0
dc.W $3000
dc.L useCancelHit
dc.L CancelStr
dc.l 0 ;color table
dc.b $1b,$1b ;escape
dc.w 0,0 ;modifiers
w320OKButton dc.W 9 ; size of the record
dc.L OKId ; appID
*** dc.W 140,205,153,265
dc.W 140+1,207,153+1,267
dc.L $80000000
dc.W 1
dc.W $3000
dc.L useOKHit
dc.L OKStr
dc.l 0 ;color table
dc.b $0d,$0d ;Return
dc.w 0,0 ;modifiers
w320CanButton dc.W 9
dc.L CancelID
*** dc.W 122,205,135,265
dc.W 122+1,207,135+1,267
dc.L $80000000
dc.W 0
dc.W $3000
dc.L useCancelHit
dc.L CancelStr
dc.l 0 ;color table
dc.b $1b,$1b ;escape
dc.w 0,0 ;modifiers
w640plainS dc.W 10
dc.L PlainSID
dc.W 90-2,17,100-2,122
dc.L $82000000
dc.W 0 ; flags (visible)
dc.W $3000 ; MoreFlags (FctsProcNotPtr)
dc.L usePlainHit
dc.L Style1Str
dc.W 0 ;initial value
dc.l 0 ;color table
dc.b 'P','p'
dc.w $0100,$0100 ;Apple key
w640BoldS dc.W 10
dc.L BoldSID
dc.W 101-2,17,111-2,122
dc.L $82000000
dc.W 0 ; flags (visible)
dc.W $3000 ; MoreFlags (FctsProcNotPtr)
dc.L useStyleHit
dc.L Style2Str
dc.W 0
dc.l 0 ;color table
dc.b 'B','b'
dc.w $0100,$0100 ;Apple key
w640ItalicS dc.W 10
dc.L ItalicSID
dc.W 112-2,17,122-2,122
dc.L $82000000
dc.W 0 ; flags (visible)
dc.W $3000 ; MoreFlags (FctsProcNotPtr)
dc.L useStyleHit
dc.L Style3Str
dc.W 0
dc.l 0 ;color table
dc.b 'I','i'
dc.w $0100,$0100 ;Apple key
w640UnderS dc.W 10
dc.L UnderSID
dc.W 123-2,17,133-2,122
dc.L $82000000
dc.W 0 ; flags (visible)
dc.W $3000 ; MoreFlags (FctsProcNotPtr)
dc.L useStyleHit
dc.L Style4Str
dc.W 0
dc.l 0 ;color table
dc.b 'U','u'
dc.w $0100,$0100 ;Apple key
w640OutLineS dc.W 10
dc.L OutlineSID
dc.W 134-2,17,144-2,122
dc.L $82000000
dc.W 0 ; flags (visible)
dc.W $3000 ; MoreFlags (FctsProcNotPtr)
dc.L useStyleHit
dc.L Style5Str
dc.W 0
dc.l 0 ;color table
dc.b 'O','o'
dc.w $0100,$0100 ;Apple key
w640ShadowS dc.W 10
dc.L ShadowSID
dc.W 145-2,17,155-2,122
dc.L $82000000
dc.W 0 ; flags (visible)
dc.W $3000 ; MoreFlags (FctsProcNotPtr)
dc.L useStyleHit
dc.L Style6Str
dc.W 0
dc.l 0 ;color table
dc.b 'S','s'
dc.w $0100,$0100 ;Apple key
w640Stat1 dc.W 8
dc.L stat1ID
dc.W 4-1,15+2,14-1,122+2
dc.L $81000000
dc.W $FF01 ; pstring
dc.W $1000
dc.L useNILHit
dc.L FontStr+1
dc.W 5
w640Stat2 dc.W 8
dc.L stat2ID
dc.W 89-8,205+6,99-8,280+6
dc.L $81000000
dc.W $FF01 ; pstring
dc.W $1000
dc.L useNILHit
dc.L SizeStr+1
dc.W 5
w640Stat3 dc.W 8
dc.L stat3ID
*** dc.W 78,17,88,205
dc.W 78-1,17+4,88-1,17+4+$33 ;DAL
dc.L $81000000
dc.W $FF01 ; pstring
dc.W $1000
dc.L useNILHit
dc.L StyleStr+1
*** dc.W 6
dc.w 7 ;length of new " Style " string (DAL)
w320StyleFrame dc.w 9
dc.l styleFrameID ;control ID
dc.w 83-1,8,157-1,118
dc.l $87FF0003 ;Frame Control (from Sys.Resources)
dc.w $ff02 ;hilite=$ff, flags=10 (black)
dc.w $1000 ;moreflags
dc.l useNILHit ;who cares (we're inactive)
dc.w 1 ;pen height
dc.w 2 ;pen width in 640 mode
dc.b $aa,$55,$aa,$55,$aa,$55,$aa,$55 ;pen mask
w640StyleFrame dc.w 9
dc.l styleFrameID ;control ID
dc.w 83-1,8,157-2,118
dc.l $87FF0003 ;Frame Control (from Sys.Resources)
dc.w $ff02 ;hilite=$ff, flags=10 (black)
dc.w $1000 ;moreflags
dc.l useNILHit ;who cares (we're inactive)
dc.w 1 ;pen height
dc.w 2 ;pen width in 640 mode
dc.b $cc,$00,$cc,$00,$cc,$00,$cc,$00 ;pen mask
FontStr str 'Font:'
***StyleStr str 'Style:'
StyleStr str ' Style '
SizeStr str 'Size:'
OtherStr1 str 'Other'
OtherStr2 str 'Size:'
OKStr str 'OK'
CancelStr str 'Cancel'
Style1Str str 'Plain'
Style2Str str 'Bold'
Style3Str str 'Italic'
Style4Str str 'Underline'
Style5Str str 'Outline'
Style6Str str 'Shadow'
; END of Font manager data area
EndP
EJECT
*******************************************************************************
*
GetROMResource PROC EXPORT
*
* Description: This call will return a 'handle' to the data requested by the
* ROM routine. This will either be a fake handle that exists
* only in ROM, or a real resource loaded from disk. The tool
* should not treat this resouce any different from a handle,
* except that it is always to be treated as read only. The
* parameters of this call are identical to those of the
* real resource manager. Please refer to then for further
* details.
*
*
* Inputs: On Stack
* | previous contents |
* +---------------------+
* | |
* +-- LongSpace --+ LONG Room for result
* | |
* +---------------------+
* | resource type | WORD Type of resource to find
* +---------------------+
* | |
* +-- resource ID --+ LONG ID of resource to load
* | |
* +---------------------+
* | | <- SP
*
*
*
* Outputs: On Stack
* | previous contents |
* +---------------------+
* | |
* +-- Data Handle --+ LONG Handle to data storage
* | |
* +---------------------+
* | | <- SP
*
*
* Errors: Memory manager errors
* $0310 Requested data does not exist
* This can only happen if a ROM version of the data
* does not already exist.
*
* External Refs:
*
* Entry Points:
*
*******************************************************************************
With ROMDataArea
;
; Equates for use with our stack frame...
SaveDPage equ 1
RetAddr1 equ SaveDPage+2
RetAddr2 equ RetAddr1+3
resID equ RetAddr2+3
ResType equ ResID+4
result equ resType+2
phd ; save the current dpage
tsc ; get the stack pointer
tcd ; and make it the direct page...
stz <result ; first zero out the result
stz <result+2
;
; Since this tool is going to work with the resource manager, we will first
; test to see if the resource manager is running with the status call
pea $0000 ; room for result
_ResourceStatus
pla
beq UseROMData ; if this is false, use the ROM data
;
; If the resource manager is running, try to load the resource that we want.
pha ; room for result
pha
lda <ResType ; type of resource to load
pha
lda <ResID+2 ; ID of resource to load
pha
lda <ResID
pha
_Loadresource ;attempt to load the resource from the file
pla ; get the result for a second...
plx
bcs UseROMData ; if an error occured, us the ROM resource
;
; If we get this far then we have loaded the resource from the resource file,
; and we should just return its handle to the caller...
sta <result ; store the result in result
stx <result+2
ldy #0 ; error code ...
brl GRRDone ; and end the call
;
UseROMData
; This routine will be called when the apropriate resource is not available, it will
; look thru the ROM data tables and pick out the proper handle from the list. If it
; can not find a proper resource in the list, it will simply bomb with a data not
; found error
ldx #0 ; init our counter
FindLoop lda >TypeList,x ; load in the first type
cmp <resType ; does it match our desired id?
bne tryNext ; if not, try the next one
lda >IDList,x ; next try the ID list
cmp <ResID ; see if the ID matches
bne tryNext ; if not try the next one
lda >IDList+2,x ; now the high byte of the ID
cmp <ResID+2
bne tryNext
bra FoundROMData ; if all tests match, then we found the ROM data
tryNext
lda >TypeList,x ; test to see if we are at the end of the list
ora >IDList,x ; by finding 0's in the type and ID field
ora >IDList+2,x
beq NoROMData ; if this is zero, then there is no ROM data
txa ; bump our counter
clc
adc #SizeofEntry ; by the size of each entry
tax ; and try the next one...
bra FindLoop
NoROMData
;
; This routine places an error into Y and ends
ldy #$0310 ; data not found error
brl GRRDone
FoundROMData
;
; This routine sets up the proper result and returns it to the caller.
txa ; put table offset into <A>
clc ; and create a pointer to our pointer
adc #HandleTbl
sta <Result
lda #0
adc #HandleTbl>>16
sta <Result+2
ldy #0
;
GRRDone
; This routine moves the return address on the stack and then tests <Y> for an
; error code, and returns.
lda <RetAddr1 ; move the return address
sta <ResID
lda <RetAddr1+2
sta <ResID+2
lda <RetAddr1+4
sta <ResID+4
pld ; recover the direct page
plx ; remove 6 bytes of data
plx
plx
tya ; put the return address into <A>
cmp #1 ; set the carry
rtl ; and leave
EndP
EJECT
*******************************************************************************
*
ReleaseROMResource PROC EXPORT
*
* Description: This call releases a resource that was given by the
* GetROMResource call. It should be made for all data
* that you retrieve even if its in firmware.
*
*
* Inputs: On Stack
* | previous contents |
* +---------------------+
* | resource type | WORD Type of resource to release
* +---------------------+
* | |
* +-- resource ID --+ LONG ID of resource to release
* | |
* +---------------------+
* | | <- SP
*
*
*
*
*
* Outputs: On Stack
* | previous contents |
* +---------------------+
* | | <- SP
*
*
* Errors: Memory manager errors
*
* External Refs:
*
* Entry Points:
*
*******************************************************************************
With ROMDataArea
;
; Equates for use with our stack frame...
SaveDPage equ 1
RetAddr1 equ SaveDPage+2
RetAddr2 equ RetAddr1+3
resID equ RetAddr2+3
ResType equ ResID+4
phd ; save the current dpage
tsc ; get the stack pointer
tcd ; and make it the direct page...
;
; Since this tool is going to work with the resource manager, we will first
; test to see if the resource manager is running with the status call
pea $0000 ; room for result
_ResourceStatus
pla
beq UseROMData ; if this is false, use the ROM data
;
; If the resource manager is running, release the given resource.
pea $0003 ; set to highest purge factor
lda <ResType ; type of resource to release
pha
lda <ResID+2 ; ID of resource to release
pha
lda <ResID
pha
_ReleaseResource ;attempt to load the resource from the file
bcs UseROMData ; if an error occured, us the ROM resource
;
ldy #0 ; error code ...
brl GRRDone ; and end the call
;
UseROMData
ldy #0
;
GRRDone
; This routine moves the return address on the stack and then tests <Y> for an
; error code, and returns.
lda <RetAddr1 ; move the return address
sta <ResID
lda <RetAddr1+2
sta <ResID+2
lda <RetAddr1+4
sta <ResID+4
pld ; recover the direct page
plx ; remove 6 bytes of data
plx
plx
tya ; put the return address into <A>
cmp #1 ; set the carry
rtl ; and leave
EndP
END