set color and paper
set color and paper
Hello,
do you know how i can set paper and ink in 6502 ? dont find documentations ..
how can i call these rom subroutine ?
paper and ink rom adresse : #EAFC
try to put color in A register and call subroutine but it dont work ?
do you know how i can set paper and ink in 6502 ? dont find documentations ..
how can i call these rom subroutine ?
paper and ink rom adresse : #EAFC
try to put color in A register and call subroutine but it dont work ?
Re: set color and paper
If you search in OSDK\lib, you will find a "library.ndx" file, which contains the list of all supported routines, including paper and ink:
from that you can see that paper and ink are in "graphics.s" which is at the same location:
the getXparm is also in the index file:
which is implemented that way:
So basically what the code does, is to take the input parameter on the C stack and it writes it to the array that starts in $2E0 (PARAMS) which is used by all the graphics functions, $2E0 itself is used as the error code in case of wrong parameters.
So I guess in your case if you want to call these functions, all you need to do is:
- Clear $2E0
- Write the INK or COLOR value in $2E1
- Call either $f204 or $f210
That being said, if you do that, you are basically calling the ROM; which means you are forfeiting the top 16K of overlay memory, so I would suggest to use your own routine to do that, which additionally allows you to put the color attributes were you want, like INK first and then PAPER, to limit the visually lost column used by INK, all you need is a simple loop that write two bytes from A000 to A000+40*200, skipping every 40 bytes
Code: Select all
-graphics.s
(...)
_paper
_ink
(...)
Code: Select all
_paper
ldx #1 ;Get one parm
jsr getXparm
jsr $f204 ;paper
jmp grexit ;common exit point
_ink
ldx #1 ;Get one parm
jsr getXparm
jsr $f210 ;ink
jmp grexit ;common exit point
Code: Select all
-ggeneral.s
getXparm
(...)
Code: Select all
getXparm ; Get X params (16bit) from stack
ldy #0 ; X is the number of params
sty $2e0 ; Zero error indicator.
stx tmp ; store X in storage byte
ldx #0
getXloop
lda (sp),y
sta $2e1,x
inx
iny
lda (sp),y
sta $2e1,x
inx
iny ;
dec tmp ; decrement pointer
bne getXloop
rts
So I guess in your case if you want to call these functions, all you need to do is:
- Clear $2E0
- Write the INK or COLOR value in $2E1
- Call either $f204 or $f210
That being said, if you do that, you are basically calling the ROM; which means you are forfeiting the top 16K of overlay memory, so I would suggest to use your own routine to do that, which additionally allows you to put the color attributes were you want, like INK first and then PAPER, to limit the visually lost column used by INK, all you need is a simple loop that write two bytes from A000 to A000+40*200, skipping every 40 bytes
- mikeb
- Flight Lieutenant
- Posts: 282
- Joined: Wed Sep 05, 2018 8:03 pm
- Location: West Midlands, UK
- Contact:
Re: set color and paper
This is true, of course the normal Oric BASIC screen (TEXT mode) writes PAPER first *then* INK, revelling in the two "lost" columns! I wonder why? Was it to stop people seeing a 39-column screen and thinking they'd been short changed?
If you start the line with INK then PAPER, your first column will have a black background (default at the start of every line is black paper, white ink, until told otherwise).
Re: set color and paper
Thank you Dbug for yours precisions.Dbug wrote: ↑Mon Aug 24, 2020 6:17 pm If you search in OSDK\lib, you will find a "library.ndx" file, which contains the list of all supported routines, including paper and ink:from that you can see that paper and ink are in "graphics.s" which is at the same location:Code: Select all
-graphics.s (...) _paper _ink (...)
the getXparm is also in the index file:Code: Select all
_paper ldx #1 ;Get one parm jsr getXparm jsr $f204 ;paper jmp grexit ;common exit point _ink ldx #1 ;Get one parm jsr getXparm jsr $f210 ;ink jmp grexit ;common exit point
which is implemented that way:Code: Select all
-ggeneral.s getXparm (...)
So basically what the code does, is to take the input parameter on the C stack and it writes it to the array that starts in $2E0 (PARAMS) which is used by all the graphics functions, $2E0 itself is used as the error code in case of wrong parameters.Code: Select all
getXparm ; Get X params (16bit) from stack ldy #0 ; X is the number of params sty $2e0 ; Zero error indicator. stx tmp ; store X in storage byte ldx #0 getXloop lda (sp),y sta $2e1,x inx iny lda (sp),y sta $2e1,x inx iny ; dec tmp ; decrement pointer bne getXloop rts
So I guess in your case if you want to call these functions, all you need to do is:
- Clear $2E0
- Write the INK or COLOR value in $2E1
- Call either $f204 or $f210
That being said, if you do that, you are basically calling the ROM; which means you are forfeiting the top 16K of overlay memory, so I would suggest to use your own routine to do that, which additionally allows you to put the color attributes were you want, like INK first and then PAPER, to limit the visually lost column used by INK, all you need is a simple loop that write two bytes from A000 to A000+40*200, skipping every 40 bytes
so when i compile with graphics.s I have :
Code: Select all
Building the program D at adress $600
Assembling main.S
Assembling displayhires.S
Assembling keyboard.S
Assembling shifttables.S
Assembling graphics.S
Linking
D:\osdk\sample\assembly\cwadbook
Unresolved external: sp
Unresolved external: tmp
Errors durink link.
ERROR : Build failed.
Appuyez sur une touche pour continuer...
I dont find where tmp and sp is déclared
Re: set color and paper
I sometime encounter this kind of issue. I usually solve it by:
- cleaning the BUILD directory of the project,
- cleaning the TMP directory of the OSDK directory
- closing the cmd windows and reopening a fresh one
- crossing finger and praying
I don't know exactly which step is important, but it usually fixes the problem.
As Dbug said, you could obtain the same result as the ink and paper commands by simply writing the corresponding attribute in graphic memory.
Look at here if you want to find inspiration:
https://github.com/oric-software/BattleZone4Oric/blob/master/Main.c#L166
It mainly comes from the article that you certainly have already read:
https://osdk.org/index.php?page=articles&ref=ART9
Re: set color and paper
For this particular issue the ONLY relevant solution is:
- use a simple 'main.c' file which purpose is only to call your '_asm_main' function, i.e.
- define all missing symbols which are mostly placed in the ZEROPAGE, i.e.
I recommend to start with the first option as more simple .
Now seriously: There is one BIG difference which should be always taken into account and it is: what type is your project: [C with some ASM functions eventually] or [ASSEMBLER ONLY]. If you have C code then you don't need to care about such symbols like 'sp', 'tmp', etc - they are automatically defined and linked. But when you use only ASM sources these are undefined. So, you have 2 options:
- use a simple 'main.c' file which purpose is only to call your '_asm_main' function, i.e.
Code: Select all
// this is the assembler entry function
void asm_main();
// this is the default C entry function
void main() {
asm_main();
}
Code: Select all
.zero
sp .word 0
tmp .byte 0
....
Re: set color and paper
Two things:
- Please cut some of the content when you quote, else we have to scroll down through content which was already read by everybody (use the "Preview" button if necessary)
- Please attach some actual source code, ideally the minimal complete project that shows the problem so it can be reproduced
There are many reasons about why you program failed, including having OSDKLINK=-B in the options, but without having the actual code it's hard to know.
Re: set color and paper
finally I created the following code :
Is there a more optimal code...?
Is there a more optimal code...?
Code: Select all
_set_hires_colors ; set paper and ink color in hires mode.
.(
ldy #200
suite
lda ScreenAdressLow,y
sta writepaper+1
sta writeink+1
lda ScreenAdressHigh,y
sta writepaper+2
sta writeink+2
lda papercolor
writepaper
sta $1234
inc writeink+1
lda inkcolor
writeink
sta $1234
dey
bne suite
rts
.)
Re: set color and paper
I don't think the "inc writeink+1" is correct, because if the value was 255 it will not increment the high byte value, but instead you could do that:
Also by starting at 200, you are accessing the screen address array off by one (it goes from 0 to 1999), so probably use "lda ScreenAdressLow-1,y"
" instead of "lda ScreenAdressLow,y" (and same for High).
But please, give me your (complete) original code that shows the error, else I can't fix things.
Code: Select all
ldx #1
suite
(...)
lda inkcolor
writeink
sta $1234,x
" instead of "lda ScreenAdressLow,y" (and same for High).
But please, give me your (complete) original code that shows the error, else I can't fix things.
Re: set color and paper
thx dbug, your solution works fine!Dbug wrote: ↑Thu Aug 27, 2020 5:39 pm I don't think the "inc writeink+1" is correct, because if the value was 255 it will not increment the high byte value, but instead you could do that:Also by starting at 200, you are accessing the screen address array off by one (it goes from 0 to 1999), so probably use "lda ScreenAdressLow-1,y"Code: Select all
ldx #1 suite (...) lda inkcolor writeink sta $1234,x
" instead of "lda ScreenAdressLow,y" (and same for High).
But please, give me your (complete) original code that shows the error, else I can't fix things.
I learn day after day ... thanks to you and others members