Editing
SmartBox OS
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Starting Up == The setup procedure for setting up extension job calls is to: # Claim the number of JobCodes you want #: if success: # patch the internal_vec and unknownjob_vec vectors # move LOMEM up to protect your program # do anything else for initial startup you may want to do # return back, ready and waiting This in code looks like: <nowiki>execute LDX #no_of_calls ; Number of JobCodes wanted LDA #1 ; CALLOS, function 1, Claim JobCodes JSR OS_CALLOS ; Call CALLOS CPX #0 ; Check we were given some codes BEQ noinstall ; No, don't bother installing ourself STX call ; Store base address of JobCodes allocated STY job_id ; Store JOB ID given LDA internal_vec ; Get old internal_vec (LSB) STA ovec ; Store it LDA internal_vec+1 ; Get old internal_vec (MSB) STA ovec+1 ; Store it LDA #>internal_handle ; Our internal handler (LSB) STA internal_vec ; Place it in the vector (LSB) LDA #<internal_handle ; Our internal handler (MSB) STA internal_vec+1 ; Place it in the vector (MSB) LDA unknownjob_vec ; Get old unknownjob_vec (LSB) STA ovec2 ; Store it LDA unknownjob_vec+1 ; Get old unknownjob_vec (MSB) STA ovec2+1 ; Store it LDA #>job_handle ; Our unknown job handler (LSB) STA unknownjob_vec ; Place it in the vector (LSB) LDA #<job_handle ; Our unknown job handler (MSB) STA unknownjob_vec+1 ; Place it in the vector (MSB) LDX #>WriteLomem ; Point to JobName LDY #<WriteLomem JSR findjob ; Find WriteLomem code BEQ noinstall ; Doesn't exist ! LDX #>end_of_code ; End of code (LSB) LDY #<end_of_code ; End of code (MSB) STX jobin_buf ; Place it in jobin_buf (LSB) STY jobin_buf+1 ; Place it in jobin_buf+1 (MSB) JSR OS_DECODEJOB ; Call JobCall handler noinstall RTS ; End - return to OS findjob STX zero.gp1 ; Zero page STY zero.gp1+ LDY #0 findthisjoblo LDA (zero.gp1),Y STA jobin.buf,Y ; Store name in jobin_buf INY CMP #13 BNE findthisjoblo LDA #3 ; NameCode JSR OS.DECODEJOB ; Call NameCode LDA jobout.buf ; Get returned value RTS WriteLomem STR "WriteLomem"</nowiki> This will setup the various vectors and memory pointers for the applicaion, the actual routines (internal_handle and job_handle) are fairly straight forward and simple: <nowiki>internal_handle CMP #1 : Is it function call 1 (NameCode) ? BNE internal_handle_2 ; No, check for function 2 LDA job_id ; Get our JOB ID number STA zero_gp3 ; Place it in zero_gp3 for CALLOS LDX #>job_names ; Our Job name table (LSB) LDY #<job_names ; Our Job name table (MSB) LDA #2 ; CALLOS function 2 JSR OS_CALLOS ; Call CALLOS BCC internal_yes : Found, go off and claim call LDA #1 ; Not found, restore A JMP (ovec) ; Call back to old vector internal_handle_2 CMP #2 ; Is it function call 2 (CodeName) ? BNE internal_handle_3 ; No, unknown, pass on LDA job_id ; Get our JOB ID STA zero_gp3 ; Place it in zero_gp3 for CALLOS LDX #>job_names ; Our Job name table (LSB) LDY #<job_names ; Our Job name table (MSB) LDA #3 ; CALLOS function 3 JSR OS_CALLOS ; Call CALLOS BCC internal_yes ; Found, go off and claim call LDA #2 ; Not found, restore A JMP (ovec) ; Call back to old vector internal_yes LDA #0 ; We want to claim call for some reason internal_handle_3 JMP (ovec) ; Call back to old vector job_handle PHA ; Mark sure to preserve A CPY call ; Check call wanted against base of ours BCC job_handle_no ; Less than our base, so definately not ours TYA SBC #no_of_calls ; Subtract number of calls we have CMP call ; Now compare with base BCC job_handle2 ; Yes, one of ours job_handle.no PLA ; Restore A JMP (ovec2) ; Call back to old vector job_handle2 TYA SEC SBC call ; Subtract our base from call ASL A ; Times by 2 for offset into table TAY ; Place in Y LDA job_run_table,Y ; Get LSB of routine STA zero_gp1 ; Store it for indirect jump (LSB) LDA job_run_table+1,Y ; Get MSB of routine STA zero_gp1+1 ; Store it for indirect jump (MSB) PLA ; Restore A JMP (zero_gp1) ; Call our relevant routine job_names ; List of our JobNames STR "TestJob" ; Test job name DFB &FF ; &FF - marks end of table job_run_table ; List of routine addresses to match Jobs DFW job_TestJob ; Test job routine</nowiki>
Summary:
Please note that all contributions to Smart Box may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Smart Box:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
British English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information