Jump to content
IGNORED

The "funkheld" Question Thread


funkheld

Recommended Posts

Hi Funkheld!

 

how can you please implement the program below in fastbasic.

 

PROC DLI()
  BYTE WSYNC=$D40A
  BYTE COLPF2=$D018
 
  [PHA TXA PHA TYA PHA]    
  WSYNC=0
  COLPF2=$CC
  VSDLST=DLI2V
  [PLA TAY PLA TAX PLA RTI]  
RETURN

 

Because FastBasic is an interpreted language, you can't write an interrupt routine in it. You need to use machine language.

 

Something equivalent to your code is:

' Display List Interrupt example
'

' Assembly:       PHA/TXA/PHA/TYA/PHA/LDA#$00/STA $D40A
data dli() byte = $48,$8a,$48,$98,$48,$a9,$00,$8d,$0a,$d4,
'                 LDA#$CC/STA $D01A  /PLA/TAY/PLA/TAX/PLA/RTI
data       byte = $a9,$cc,$8d,$1A,$d0,$68,$a8,$68,$aa,$68,$40


' Set's graphics mode
gr. 7

' Draw some lines
plot 79,47
for i=0 to 100
  color rand(3)+1
  dr. rand(160),rand(96)
next i

dpoke 512, ADR(dli)     ' Sets display-list interrupt
poke dpeek(560)+40, $8D ' Writes an interrupt line in the display-list
poke 54286, 192         ' Enable DLI

? "Press any key to exit";
repeat : until key()
Link to comment
Share on other sites

hello, that's wonderful with fastbasic ... !!!!!


I have my own displaylist in memory from $ 2100.

the interrupt works wonderfully.



Without manipulation of fastbasic.cfg is a graphic representation with Players difficult.

Especially affects Graphics 24.



Thank you.





dlist =560
savmsc=$58
ramadr=$2100
max=3840

ramtop = $6a : sdmctl = $22f : pcolr0 = $2c0
hposp0 = $d000 : gractl = $d01d : pmbase = $d407
p0pf = $d004 : hitclr = $d01e : pm0br = $d008 : vdelay = $d01c

' Assembly: PHA/TXA/PHA/TYA/PHA/LDA#$00/STA $D40A
data dli() byte = $48,$8a,$48,$98,$48,$a9,$00,$8d,$0a,$d4,
' LDA#$CC/STA $D01A /PLA/TAY/PLA/TAX/PLA/RTI
data byte = $a9,$cc,$8d,$1A,$d0,$68,$a8,$68,$aa,$68,$40

data dldat() byte = $70, $70, $70, $4d,
data byte = $00,$21,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $41,
data byte = $00, $20

dladr=adr(dldat)
move dladr,$2000,255

memtop = peek(ramtop) - 8
p0mem = $100 * memtop + $400
for a=(memtop*256) to (memtop*256+2047)
poke a,0
next

oldpos = p0mem
poke ramtop, memtop

gr. 23
color 1

dpoke dlist,$2000
dpoke savmsc,ramadr

plot 0,0
drawto 159,95
plot 159,0
drawto 0,95

dpoke 512, ADR(dli) ' Sets display-list interrupt
poke dpeek(560)+60, $8D ' Writes an interrupt line in the display-list
poke 54286, 192 ' Enable DLI

poke p0mem, 0 : move p0mem, p0mem+1, 127
poke pcolr0, $1f
poke sdmctl, peek(sdmctl) ! 24
poke pmbase, memtop
poke gractl, 2

data pmdata() byte = 255,129,129,129,129,129,129,255
data pmclear() byte = 0,0,0,0,0,0,0,0

xpos = 50 : ypos = 50
exec movepm

repeat
joy0=stick(0)

if joy0=14
test=1
ypos=ypos-1
exec movepm
elif joy0=13
test=2
ypos=ypos+1
exec movepm
elif joy0=7
test=3
xpos=xpos+1
exec movepm
elif joy0=11
test=4
xpos=xpos-1
exec movepm
endif

if peek(p0pf) > 0
poke hitclr,1

if test=1
test=0
ypos=ypos+2
exec movepm
elif test=2
test=0
ypos=ypos-2
exec movepm
elif test=3
test=0
xpos=xpos-2
exec movepm
elif test=4
test=0
xpos=xpos+2
exec movepm
endif
endif

until key()

poke gractl, 0
poke sdmctl, peek(sdmctl) & 247
poke ramtop, memtop + 8

end

proc movepm
x = xpos : y = p0mem + ypos

pause 0
poke hposp0, x
move adr(pmclear), oldpos, 8
move adr(pmdata), y, 8
oldpos = y
endproc

post-31221-0-35367900-1537133153_thumb.jpg

Edited by funkheld
Link to comment
Share on other sites

Hello funkheld.

 

The ATARI.INC file resides in the asminc directory. It contains symbolic constants for various addresses and values, no real code. If you need to use these symbolic constants in your CA65 assembler programs, use the .INCLUDE control command to include it.

The ATARI.H file resides in the include directory. It contains C declarations and some C preprocessor macros specific to the Atari platform. Use the #include preprocessor directive to include it.

 

Yes, C version of ATARI.INC would be valuable because of the symbolic constants, but it is not available, at least not yet.

 

To incorporate atari-specific libraries (real code from the lib/atari.lib file), keep passing the -t atari command line parameter to cc65, ca65, ld65 and cl65, whatever you are using.

Link to comment
Share on other sites

hello.


On the background screen draw $3000 (dpoke savmsc, ramadr3).

the foreground screen $2000 is visible (dpoke dlist, adr2).

then 2x half of the $3000 background screen is moved to the

$2000 foreground screen with move.



Without manipulation of fastbasic.cfg is a graphic representation with Players difficult.

Especially affects Graphics 24.



---------------------------------------------------------------


FEATURES {

STARTADDRESS: default = $4100;

---------------------------------------------------------------





dlist =560
savmsc=$58

ramadr2=$2000
ramadr3=$3000

data dldat2() byte = $70, $70, $70, $4d,
data byte = $00,$20,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $41,
data byte = $00, $00

data dldat3() byte = $70, $70, $70, $4d,
data byte = $00,$30,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $41,
data byte = $00, $00

adr2=adr(dldat2)
dpoke adr2+103,adr2

adr3=adr(dldat3)
dpoke adr3+103,adr3

gr. 23
color 1

dpoke dlist,adr2
dpoke savmsc,ramadr3

plot 0,0
drawto 159,95
plot 159,0
drawto 0,95

for a=0 to 5000
next a

move ramadr3,ramadr2,1800

for a=0 to 5000
next a

move ramadr3+1800,ramadr2,1800

repeat
until key()

end


Edited by funkheld
Link to comment
Share on other sites


Hello.
now it worked with the dli with several lines.
asm-compiler is atasm.exe
created with my purebasicprogram from the bin data :
--------------------------------------------------------------------------------------------
data dli() byte =$48, $8A, $48, $A9, $01, $8D, $0A, $D4, $A9, $C5,
data byte = $8D, $1A, $D0, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
........
----------------------------------------------------------------------------------------------
Thank you.
greeting

asm-daten:

    * = start
pha
txa
pha
lda #1
sta $d40a
lda #$c5
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$89
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$41
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$69
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$0
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$89
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$0
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$a9
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$0
sta $d01a 
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
pla
tax
pla
rti

dlist =560
savmsc=$58
ramadr=$2000

data dli() byte =$48, $8A, $48, $A9, $01, $8D, $0A, $D4, $A9, $C5,
data byte = $8D, $1A, $D0, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $A9, $89, $8D,
data byte = $1A, $D0, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $A9, $41, $8D, $1A,
data byte = $D0, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $8D, $0A, $D4, $A9, $69, $8D, $1A, $D0,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $A9, $00, $8D, $1A, $D0, $8D,
data byte = $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $A9, $89, $8D, $1A, $D0, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $A9, $00, $8D, $1A, $D0, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $A9, $A9, $8D, $1A, $D0, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $A9, $00, $8D, $1A, $D0, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $68, $AA, $68, $40

data dldat() byte = $70, $70, $70, $4d,
data byte = $00,$20,
data byte = $8D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $41,
data byte = $00, $00
dladr=adr(dldat)
poke dladr+103,dladr
dpoke dlist,dladr
dpoke savmsc,ramadr
dpoke 512, ADR(dli)
poke 54286, 192
repeat
until key()
end
[code=auto:0]

post-31221-0-39080800-1537216800.jpg

Edited by funkheld
  • Like 1
Link to comment
Share on other sites

Hi!

 

 

how can you use fastbasic a HEX: "Print hex (54000)" ??? > D2F0

If there is such a built-in function, I guess it should be HEX$(). But I don't know if it would be useful outside the scope of an utility.

 

Yes, currently there is no HEX$() in FastBasic, as I never used it :)

 

Why do you need that function?

 

Currently, it can be implemented as a (somewhat long) PROC:

HEX$=""
' Test conversion for many numbers:
HEXN=$0000:EXEC HEX:? HEX$
HEXN=$0001:EXEC HEX:? HEX$
HEXN=$1234:EXEC HEX:? HEX$
HEXN=$7FFF:EXEC HEX:? HEX$
HEXN=$8000:EXEC HEX:? HEX$
HEXN=$C123:EXEC HEX:? HEX$
HEXN=$FFFF:EXEC HEX:? HEX$

' Converts number HEXN to string HEX$
PROC HEX
 DATA HTAB() BYTE = 48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70
 IF HEXN < 0
  HEXN=HEXN-32768
  HEX$=CHR$(HTAB(8+HEXN/4096))
 ELSE
  HEX$=CHR$(HTAB(HEXN/4096))
 ENDIF
 HEX$=+CHR$(HTAB(HEXN/256 MOD 16))
 HEX$=+CHR$(HTAB(HEXN/16 MOD 16))
 HEX$=+CHR$(HTAB(HEXN MOD 16))
ENDPROC
  • Like 1
Link to comment
Share on other sites

Hi Funkheld!

 

hello thanks.

 

this code not funktion in fastbasic.

 

greeting.

Oh, sorry, I used the CHR$() function, so it needs the last development version... I attached the last version for you to try.

 

Also, you don't reply why do you need the HEX$() function?

fastbasic-v3.5-13-g6ef7472.atr

fastbasic-v3.5-13-g6ef7472-linux64.zip

fastbasic-v3.5-13-g6ef7472-win32.zip

Link to comment
Share on other sites

fastbasic : three bars walk with the dli down and up.


greeting




dlist =560
savmsc=$58
ramadr=$2100

data dli() byte =$48, $8A, $48, $A9, $01, $8D, $0A, $D4, $A9, $C5,
data byte = $8D, $1A, $D0, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $A9, $69, $8D,
data byte = $1A, $D0, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A,
data byte = $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $A9, $89, $8D, $1A,
data byte = $D0, $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4,
data byte = $8D, $0A, $D4, $8D, $0A, $D4, $8D, $0A, $D4, $8D,
data byte = $0A, $D4, $A9, $00, $8D, $1A, $D0, $68, $AA, $68,
data byte = $40

data dldat() byte = $70, $70, $70, $4d,
data byte = $00,$21,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D, $0D,
data byte = $0D, $0D, $0D, $0D, $0D, $41,
data byte = $00, $20

dladr=adr(dldat)
move dladr,$2000,255

dpoke dlist,$2000
dpoke savmsc,ramadr

for z=0 to 10
for a=7 to 95
dpoke 512, ADR(dli)
poke dpeek(560)+a-1, $0D
poke dpeek(560)+a, $8D
poke 54286, 192
pause 0
next a
for b=95 to 7 step -1
dpoke 512, ADR(dli)
poke dpeek(560)+b, $0D
poke dpeek(560)+b-1, $8D
poke 54286, 192
pause 0
next b
next z

repeat
until key()

post-31221-0-98471300-1537391591.jpg

Edited by funkheld
Link to comment
Share on other sites

fastbasic.cfg:


FEATURES {
STARTADDRESS: default = $3000;
}
SYMBOLS {
__EXEHDR__: type = import;
__STARTADDRESS__: type = export, value = %S;
}
MEMORY {
ZP: file = "", define = yes, start = $0094, size = $0040;

# file header, just $FFFF
HEADER: file = %O, start = $0000, size = $0002;

# "main program" load chunk
MAINHDR: file = %O, start = $0000, size = $0004;
MAIN: file = %O, define = yes, start = %S, size = $CFFF - %S;
# code in zero page!
IHEADER: file = %O, start = $0000, size = $0004;
INTERP: file = %O, define = yes, start = $0082, size = $0012;
TRAILER: file = %O, start = $0000, size = $0006;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
EXEHDR: load = HEADER, type = ro, optional = yes;
MAINHDR: load = MAINHDR, type = ro, optional = yes;
JUMPTAB: load = MAIN, type = ro, define = yes, align = $100;
RUNTIME: load = MAIN, type = rw, define = yes;
CODE: load = MAIN, type = rw, define = yes;
DATA: load = MAIN, type = rw optional = yes, define = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
IHEADER: load = IHEADER, type = ro;
INTERP: load = INTERP, type = rw;
AUTOSTRT: load = TRAILER, type = ro, optional = yes;
}




asm-dli:



* = start
pha
txa
pha
lda #1
sta $d40a
lda #$c5
sta $d01a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$69
sta $d01a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$89
sta $d01a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
sta $d40a
lda #$0
sta $d01a
pla
tax
pla
rti
Edited by funkheld
Link to comment
Share on other sites

Some tips:
1) Where you did "dlist =560", you can also state "dlivec=512"
2) "dpoke 512, ADR(dli)" only needs to be executed once, i.e. it doesn't need to be redone within your loops.
Therefore add before the 'z' loop "dpoke dlivec, ADR(dli)".
3) Similarly, the above 1&2 should be done with declaring "nmien=54286".
Remove it from inside the loops and so before the 'z' loop "poke nmien, 192".
4) [Edit] You do not use the X register in the DLI and so pushing and pulling it from the stack is also not required, the single PHA at the start and PLA at the end will suffice.
As an exercise, see if you can chain 4 separate DLIs together to achieve the same thing and eliminate the repeated "sta $d40a" in the single DLI.
Edited by Wrathchild
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...