Ok, I have the $w command working as I want in the compiler.
I'm trying to come up with a better solution to get the address of a procedure in GFA. The searching method works but its messy.
Stay tuned.
$F< !do not check for missing returns in functions (required)
'
' If you need the addresses of several routines, just copy function get_int_adr
' put it above the routine you want the address of, and rename it to something else.
' Then call it. Its that easy and no searching.
'
addr%=@get_int_adr
PRINT "$";HEX$(WORD{addr%},4) !dump the first word of the interrupt as a test
' if you see $48E7, it worked!
EDIT
'
FUNCTION get_int_adr !this routine must be right above the one you want the address of
$F% !return an integer and not a float (required)
~BASEPAGE !basepage -> d0 (we need a temporary place to store the address)
$w 2040 !move.l d0,a0 ;we know a call to BASEPAGE uses d0
$w 43FA0012 !lea ref(pc),a1 ;this fetches the address of the routine below it
$w 21490080 !move.l a1,128(a0) ;stuff the address into our temporary location
RETURN LONG{BASEPAGE+128} !fetch the address from our temporary location
ENDFUNC
PROCEDURE interrupt
' ref:
$w 48E78080 !movem.l d0/a0,-(a7)
' interrupt code here
$w 4CDF0101 !movem.l (a7)+,d0/a0
$w 4E73 !rte
RETURN !this rts is never reached (becomes dead code)
STARTADR: jsr INIT.l
UserCode: jsr _GET_INT.l
move.l d0,-32768(a5)
moveq #36,d0
bsr P0RCHR
movea.l -32768(a5),a0
move.w (a0),d0
ext.l d0
move.l d0,d1
moveq #4,d0
bsr HEXISTR
bsr PXSTR
bsr END
_GET_INT: bsr BASEPAGE
movea.l d0,a0
lea _INTERRU(pc),a1
move.l a1,128(a0)
bsr BASEPAGE
movea.l d0,a0
move.l 128(a0),d0
rts
_INTERRU: movem.l d0/a0,-(a7)
movem.l (a7)+,d0/a0
rte
rts
' Line #803
shl_write(1+8*256,0,100,info_chemin$(3),CHR$(len_tail|)+gfa_name$+co$+c0$) !old
shl_write(1+8*256,0,100,info_chemin$(3),CHR$(len_tail|)+gfa_name$+".gfa"+co$+c0$) !new
' Line #811
e%=EXEC(0,info_chemin$(3),CHR$(len_tail|)+gfa_name$+co$+c0$,env$) !old
e%=EXEC(0,info_chemin$(3),CHR$(len_tail|)+gfa_name$+".gfa"+co$+c0$,env$) !new
'
$F< !do not check for missing returns in functions (required)
'
RESERVE 60000
'
buffer%=MALLOC(3040) ! main buffer
raster%=buffer% ! colour 15 rasters buffer
raster_buffer%=ADD(raster%,800) ! bars buffer 1
raster_buffer2%=ADD(raster_buffer%,400) ! bars buffer 2
sincb%=ADD(raster_buffer2%,400) ! sine wave buffer
pal%=MALLOC(32)
'
super%=GEMDOS(&H20,L:0) !supervisor mode
'
rez&=XBIOS(4) ! backup resolution
IF rez& ! not low rez ?
~XBIOS(5,L:-1,L:-1,0) ! low rez !
ENDIF
.
@calc_me_some_colours
@calc_me_a_sine_wave
.
CLS
OUT 4,18 ! no more
HIDEM ! mouse
CLS
.
BMOVE &HFFFF8240,pal%,32 ! backup current palette
FOR i&=0 TO 15 ! paint
SETCOLOR i&,0 ! in
NEXT i& ! black
@print_me_something
.
' locate address of procedure to be in interrupt
vga%=@get_int_adr
.
vector120%=LONG{&H120} ! backup vector $120
inter|=BYTE{&HFFFA09} ! backup interrupts
BYTE{&HFFFA09}=0 ! cut interrupts
BYTE{&HFFFA1B}=0 ! disable timer b
BYTE{&HFFFA17}=BSET(BYTE{&HFFFA17},3) ! SOFTWARE END OF INTERRUPT
'
LONG{&H120}=vga% ! put procedure in timer b vector
'
BYTE{&HFFFA07}=BYTE{&HFFFA07} OR 1 ! turn on timer b in enable a
BYTE{&HFFFA13}=BYTE{&HFFFA13} OR 1 ! turn on timer b in mask a
BYTE{&HFFFA21}=1 ! number of counts
'
REPEAT
VSYNC
BYTE{&HFFFA1B}=0 ! stop timer b
SWAP raster_buffer%,raster_buffer2%
rst%=raster_buffer% ! pointer in the displayed pattern
rst2%=raster_buffer2% ! pointer in the work pattern
rst2_max%=ADD(raster_buffer2%,400) ! pointer to the end of pattern
ADD rst15&,2 ! scroll in col 15 raster pattern
IF rst15&=386 ! loop
rst15&=0
ENDIF
rst15%=ADD(raster%,rst15&) ! pointer in col 15 raster pattern
.
REPEAT ! waits for 1st
b|=BYTE{&HFFFF8209} ! scanline
UNTIL b| ! to be
~SHL(13,-b|) ! reached
.
BYTE{&HFFFA1B}=8 ! set to event count mode=launch
.
coul0&=0
REPEAT ! clear
CARD{rst2%}=0 ! work
ADD rst2%,2 ! raster
UNTIL rst2%=rst2_max% ! pattern
ADD pos_in_cb&,2 ! move inside sine wave pattern
IF pos_in_cb&=720 ! loop
pos_in_cb&=0
ENDIF
FOR nb_of_bars&=0 TO 7 ! 8 sine rasterbars
.calc pos of each rasterbar
bar%=ADD(raster_buffer2%,CARD{ADD(sincb%,ADD(pos_in_cb&,MUL(nb_of_bars&,20)))})
.
FOR i&=1 TO 13 ! each bar is 13 lines
CARD{bar%}=bar&(i&) ! write colour value in buffer
ADD bar%,2
NEXT i&
NEXT nb_of_bars&
.
UNTIL PEEK(&HFFFFFC02)=57
@fin
> FUNCTION get_int_adr !must be right above the one you want the address of
$F% !return an integer and not a float (required)
~BASEPAGE !basepage -> d0 (we need a temporary place to store the address)
$w 2040 !move.l d0,a0 ;we know a call to BASEPAGE uses d0
$w 43FA0012 !lea ref(pc),a1 ;this fetches the address of the routine below it
$w 21490080 !move.l a1,128(a0) ;stuff the address into our temporary location
RETURN LONG{BASEPAGE+128} !fetch the address from our temporary location
ENDFUNC
> PROCEDURE timer_b
' ref:
$w 48E78080 !movem.l d0/a0,-(sp) ! save registers
' interrupt code
CARD{&HFFFF8240}=CARD{rst%} ! rasterbar
CARD{&HFFFF825E}=CARD{rst15%} ! colour 15 rasters
ADD rst%,2 ! points to next
ADD rst15%,2 ! points to next
'
BYTE{&HFFFFFA0F}=BCLR(BYTE{&HFFFFFA0F},0) ! interupt is done
'
$w 4CDF0101 !movem.l (sp)+,d0/a0 ! restore registers
$w 4E73 !rte ! return from exception
RETURN
.
> PROCEDURE calc_me_some_colours
DIM bar&(13)
FOR i&=1 TO 7
bar&(i&)=i&
NEXT i&
FOR i&=8 TO 13
bar&(i&)=SUB(14,i&)
NEXT i&
r&=7
v&=0
b&=0
FOR i&=0 TO 7
b&=i&
coul&=SHL(r&,8) OR SHL(v&,4) OR b&
CARD{raster%+i&*2}=coul&
NEXT i&
a&=0
FOR i&=7 DOWNTO 0
r&=i&
coul&=SHL(r&,8) OR SHL(v&,4) OR b&
CARD{raster%+a&*2+16}=coul&
INC a&
NEXT i&
FOR i&=0 TO 7
v&=i&
coul&=SHL(r&,8) OR SHL(v&,4) OR b&
CARD{raster%+i&*2+32}=coul&
NEXT i&
a&=0
FOR i&=7 DOWNTO 0
b&=i&
coul&=SHL(r&,8) OR SHL(v&,4) OR b&
CARD{raster%+a&*2+48}=coul&
INC a&
NEXT i&
FOR i&=0 TO 7
r&=i&
coul&=SHL(r&,8) OR SHL(v&,4) OR b&
CARD{raster%+i&*2+64}=coul&
NEXT i&
a&=0
FOR i&=7 DOWNTO 0
v&=i&
coul&=SHL(r&,8) OR SHL(v&,4) OR b&
CARD{raster%+a&*2+80}=coul&
INC a&
NEXT i&
BMOVE raster%,raster%+96,96
BMOVE raster%,raster%+192,192
BMOVE raster%,raster%+384,384
RETURN
.
> PROCEDURE calc_me_a_sine_wave
FOR i&=0 TO 359
sincbp%=ADD(sincb%,i&*2)
CARD{sincbp%}=(92+INT(92*SINQ(i&)))*2
CARD{ADD(sincbp%,720)}=CARD{sincbp%}
NEXT i&
RETURN
.
> PROCEDURE print_me_something
'
PRINT "****************************************"
PRINT "* *"
PRINT "* *"
PRINT "* *"
PRINT "* 99 % PURE GFA DEMO *"
PRINT "* *"
PRINT "* USING LONNY PURSELL'S *"
PRINT "* *"
PRINT "* *"
PRINT "* LAST COMPILER UPDATE *"
PRINT "* *"
PRINT "* *"
PRINT "* GGGGG FFFFF AAAAA *"
PRINT "* G F A A *"
PRINT "* G GG FFF AAAAA *"
PRINT "* G G F A A *"
PRINT "* GGGGG F A A *"
PRINT "* *"
PRINT "* *"
PRINT "****************************************"
RETURN
.
PROCEDURE fin
BYTE{&HFFFA1B}=0 ! stop timer b
CLS
BMOVE pal%,&HFFFF8240,32 ! restore old palette
LONG{&H120}=vector120% ! restore old timer b vector
BYTE{&HFFFA09}=inter| ! set interrupts back
~GEMDOS(&H20,L:super%) ! back in user mode
VSYNC
OUT 4,8 ! mouse is
SHOWM ! back
~MFREE(buffer%) ! clears buffer
EDIT
RETURN
Retourner vers English section
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité