23 January 2006, 17:12 | #1 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Starting a program
When writing an asm program what sort of structure should the program take?
How should it be written, what should you take into consideration etc? ---- Do you write the routine(s) that take over the system, open a screen, set colours etc.. or some other way maybe? Are there any examples of the correct way to do this? |
23 January 2006, 17:31 | #2 |
Oldskool
Join Date: Dec 2005
Location: Norway
Age: 51
Posts: 28
|
Ususally i do it like this:
1.) Initialize : that is take over the system and put the copperlist in #$dff080, initialize DMACON ( #$dff09a) with the desired bits (if i will use sprites, bplane blitter and so on...) 2) I make what i call a waitmouse routine , like this: wm: cmp.b #$ff,$dff006 ; Vpos , rasterwait !! bne.s wm bsr Myroutine ; from here you jump to all your routines ; you can have as many bsr and routines ; as you want btst #6,$bfe001 ; Check mousebutton bne.s wm Bsr exit rts My rotuine: bla blablabla rts Copperlist: dc.w #$xxx,$xxx ; First i set DIWSTRT and so on..... ; then DIWSTOP ; FFDSTRT ; FFDSTOP ; MODULO 0 ; MODULO 1 ; BPLCON0 ; BPLCON1 ; BPLANE POINTERS ; SPRPOINTERS ; BACKGR.COLORS ; BPLANE COLORS dc,w #$ffff,$fffe ; END exit: bla bla all the exit stuff rts This is how I do it and i feel personally that this is very tidy and clean way to do it, but thats me :-) I upped in the zone last week a startupcode which was coded in this way. If you want it I can up it again...... :-) Last edited by Alter; 23 January 2006 at 20:29. |
23 January 2006, 17:41 | #3 | |
Zone Friend
Join Date: Aug 2005
Location: Germany
Age: 52
Posts: 424
|
Quote:
lea $dff000,a2 rastwait:cmp.b #255,$6(a2) bne.s rastwait |
|
23 January 2006, 18:20 | #4 |
Zone Friend
Join Date: Aug 2005
Location: Germany
Age: 52
Posts: 424
|
here is another startup (oldskool A500)
nearly exactly the same as from alter. lea $dff000,a2 move.w #$4000,$9a(a2);stopp irqs lea copperlist,a3 move.l a3,$84(a2) rastwait: cmp.b #255,$6(a2);Vpos bne.s rastwait jsr dosomestuff btst #6,$bfe001 ;waitmouse beq.s end jmp rastwait(pc) end: move.w #$c000,9a(a2);enable irqs rts copperlist: dc.w $0100,... dc.w $ffff,$fffe |
23 January 2006, 20:26 | #5 |
Oldskool
Join Date: Dec 2005
Location: Norway
Age: 51
Posts: 28
|
The only thing when you do it this way you should save the old copperlist and then return it when you exit the program , like this:
In the start, before anything else: move.l #4,a0 move.l #156(a0),a0 move.l #38(a0),coppersave then in the Exit just put : move.l coppersave,$dff080 Remember also to make a label: coppersave: dc.l 0 |
23 January 2006, 20:43 | #6 | |
Zone Friend
Join Date: Aug 2005
Location: Germany
Age: 52
Posts: 424
|
Quote:
but the startup modifies the coppersecond location high/low. 084/086. It´s not necessary to rescue copperfirts location high/low. 080/082 |
|
23 January 2006, 21:24 | #7 |
Oldskool
Join Date: Dec 2005
Location: Norway
Age: 51
Posts: 28
|
Ahh I see , you move the coplist to $dff084 , I didnt see that :-) I use $dff080 for my coplist...:-)
|
28 January 2006, 15:02 | #8 | |
Dazed and Confused
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
|
Quote:
* Startup.asm - A working tested version of startup from Howtocode6 * * Written by CJ of SAE... Freeware. Share and Enjoy! * * This code sets up one of two copperlists (one for PAL and one for NTSC) * machines. It shows something to celebrate 3(?) years since the Berlin * wall came down :-) Press left mouse button to return to normality. * Tested on Amiga 3000 (ECS/V39 Kickstart) and Amiga 1200 (AGA/V39) * * $VER: startup.asm V6.tested (17.4.92) * Valid on day of purchase only. No re-admission. No rain-checks. * Now less bugs and more likely to work. * * Tested with Hisoft Devpac V3 and Argasm V1.09d opt l-,o+ ; auto link, optimise on opt o3- ; add this for Devpac 2+ machine mc68000 ; and this for Devpac 3 section mycode,code ; need not be in chipram incdir "include:" include "exec/types.i" include "exec/funcdef.i" ; keep code simple and include "exec/exec_lib.i" ; easy to read - use include "exec/exec.i" ; the includes! include "libraries/dosextens.i" include "graphics/gfxbase.i" include "graphics/graphics_lib.i" include "iconstartup.i" ; Allows startup from icon move.l 4.w,a6 sub.l a1,a1 ; Zero - Find current task jsr _LVOFindTask(a6) move.l d0,a1 moveq #127,d0 ; task priority to very high... jsr _LVOSetTaskPri(a6) move.l 4.w,a6 ; get ExecBase lea gfxname(pc),a1 ; graphics name moveq #33,d0 ; Kickstart 1.2 or higher jsr _LVOOpenLibrary(a6) tst.l d0 beq End ; failed to open? Then quit move.l d0,gfxbase move.l d0,a6 move.l gb_ActiView(a6),wbview ; store current view address sub.l a1,a1 ; clear a1 jsr _LVOLoadView(a6) ; Flush View to nothing jsr _LVOWaitTOF(a6) ; Wait once jsr _LVOWaitTOF(a6) ; Wait again. ; Note: Something could come along inbetween the LoadView and ; your copper setup. But only if you decide to run something ; else after you start loading the demo. That's far to stupid ; to bother testing for in my opininon!!! If you want ; to stop this, then a Forbid() won't work (WaitTOF() disables ; Forbid state) so you'll have to do Forbid() *and* write your ; own WaitTOF() replacement. No thanks... I'll stick to running ; one demo at a time :-) move.l 4.w,a6 cmp.w #36,LIB_VERSION(a6) ; check for Kickstart 2 blt.s .oldks ; nope... ; kickstart 2 or higher.. We can check for NTSC properly... move.l GfxBase,a6 btst #2,gb_DisplayFlags(a6) ; Check for PAL bne.s .pal bra.s .ntsc .oldks ; you really should upgrade! Check for V1.x kickstart move.l 4.w,a6 ; execbase cmp.b #50,VBlankFrequency(a6) ; Am I *running* PAL? bne.s .ntsc .pal move.l #mycopper,$dff080 ; bang it straight in. bra.s .lp .ntsc move.l #mycopperntsc,$dff080 .lp btst #6,$bfe001 ; ok.. I'll do an input bne.s .lp ; handler next time. CloseDown: move.l wbview(pc),a1 move.l gfxbase,a6 jsr _LVOLoadView(a6) ; Fix view jsr _LVOWaitTOF(a6) jsr _LVOWaitTOF(a6) ; wait for LoadView() move.l gb_copinit(a6),$dff080 ; Kick it into life move.l a6,a1 move.l 4.w,a6 jsr _LVOCloseLibrary(a6) ; close graphics.library End: moveq #0,d0 ; clear d0 for exit rts ; back to workbench/cli wbview dc.l 0 gfxbase dc.l 0 gfxname dc.b "graphics.library",0 section mydata,data_c ; keep data & code seperate! mycopper dc.w $100,$0200 ; otherwise no display! dc.w $180,$00 dc.w $8107,$fffe ; wait for $8107,$fffe dc.w $180 co dc.w $f0f ; background red dc.w $d607,$fffe ; wait for $d607,$fffe dc.w $180,$ff0 ; background yellow dc.w $ffff,$fffe dc.w $ffff,$fffe mycopperntsc dc.w $100,$0200 ; otherwise no display! dc.w $180,$00 dc.w $6e07,$fffe ; wait for $6e07,$fffe dc.w $180,$f00 ; background red dc.w $b007,$fffe ; wait for $b007,$fffe dc.w $180,$ff0 ; background yellow dc.w $ffff,$fffe dc.w $ffff,$fffe |
|
07 February 2006, 22:50 | #9 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
|
CJ of SAE/Comrade J of Share and Enjoy.... Jolyon Ralph, thats a blast from the past
|
10 February 2006, 15:11 | #10 | |
Posts: n/a
|
Quote:
move.l #156(a0),a0 move.l #38(a0),coppersave I really would like to see the assembler which assembles those instructions above! if a0 would point to gfxbase you would do move.l 38(a0), coppersave or directly move.l 38(a0),$dff080 |
|
10 February 2006, 15:35 | #11 |
Oldskool
Join Date: Dec 2005
Location: Norway
Age: 51
Posts: 28
|
sorry, yes of course wrong spelling:
move.l 4,a0 move.l 156(a0),a0 move.l 38(a0),coppersave ....... coppersave: dc.l 0 It should compile correctly now :-) |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
External windows program communicating with program running inside WinUAE | xxxxx | support.WinUAE | 10 | 19 February 2013 09:27 |
Paint program or program....... | amigagenie | request.Apps | 2 | 29 January 2013 19:56 |
For a beginner what Program and Program language would you recommend? | amigang | New to Emulation or Amiga scene | 5 | 27 March 2012 13:06 |
P-UAE boots directly when starting the program | ipp0 | support.OtherUAE | 3 | 24 August 2011 09:31 |
Calling another program from a compiled Amos program...? | andyr | support.Apps | 3 | 24 October 2004 23:47 |
|
|