68k initialization: Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
mNo edit summary |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
== Basic init code == | == Basic init code == | ||
The initial PC value in | The initial PC value in the [[68k]] binary must be $C00402 (Init [[BIOS calls|BIOS call]]), the initial SP value must be $10F300 (end of the [[68k user RAM|user RAM]]). | ||
The entrypoints for | The entrypoints for the [[68k]] code start at $000122. See [[68k program header]]. | ||
< | <syntaxhighlight> | ||
lea $10F300, sp | lea $10F300, sp | ||
lea $10F300, a7 | lea $10F300, a7 ; Depends on assemblers | ||
move.b d0,REG_DIPSW ; Kick | move.b d0,REG_DIPSW ; Kick watchdog | ||
move.w #7,REG_IRQACK ; Acknowledge any pending interrupts | move.w #7,REG_IRQACK ; Acknowledge any pending interrupts | ||
move.w #$2700,sr ; Disable all interrupts | move.w #$2700,sr ; Disable all interrupts | ||
</ | </syntaxhighlight> | ||
See [[68k interrupts]] and [[Watchdog]] for more informations. | See [[68k interrupts]] and [[Watchdog]] for more informations. | ||
Clearing [[user RAM]]: | Clearing the [[68k user RAM]]: | ||
< | <syntaxhighlight> | ||
lea RAMSTART,a0 | lea RAMSTART,a0 | ||
move.l #($F300/4)-1,d0 ; User RAM's size is $F300, and we clear longwords (4 bytes) | move.l #($F300/4)-1,d0 ; User RAM's size is $F300, and we clear longwords (4 bytes) | ||
clram: | clram: | ||
clr.l (a0)+ | clr.l (a0)+ | ||
dbra d0,clram | dbra d0,clram | ||
</ | </syntaxhighlight> | ||
Note that this function also clears the stack. Don't make a subroutine out of it unless you're sure | Note that this function also clears the stack. Don't make a subroutine out of it unless you're sure that the return address won't be cleared. | ||
BIOS calls '''BIOSF_CLEARFIX''' ($C004C2) and '''BIOSF_CLEARSPR''' ($C004C8) can be used to clear [[sprites]] and the [[fix layer]]. | |||
Don't forget to kick the [[watchdog]] regularly in your init code if the VBL interrupt isn't enabled or doesn't kick it itself. | Don't forget to kick the [[watchdog]] regularly in your init code if the VBL interrupt isn't enabled or doesn't kick it itself. | ||
[[Category: | [[Category:Base system]] | ||
[[Category:Code]] | [[Category:Code]] |
Latest revision as of 23:37, 5 April 2012
Basic init code
The initial PC value in the 68k binary must be $C00402 (Init BIOS call), the initial SP value must be $10F300 (end of the user RAM).
The entrypoints for the 68k code start at $000122. See 68k program header.
lea $10F300, sp
lea $10F300, a7 ; Depends on assemblers
move.b d0,REG_DIPSW ; Kick watchdog
move.w #7,REG_IRQACK ; Acknowledge any pending interrupts
move.w #$2700,sr ; Disable all interrupts
See 68k interrupts and Watchdog for more informations.
Clearing the 68k user RAM:
lea RAMSTART,a0
move.l #($F300/4)-1,d0 ; User RAM's size is $F300, and we clear longwords (4 bytes)
clram:
clr.l (a0)+
dbra d0,clram
Note that this function also clears the stack. Don't make a subroutine out of it unless you're sure that the return address won't be cleared.
BIOS calls BIOSF_CLEARFIX ($C004C2) and BIOSF_CLEARSPR ($C004C8) can be used to clear sprites and the fix layer.
Don't forget to kick the watchdog regularly in your init code if the VBL interrupt isn't enabled or doesn't kick it itself.