[Coco] ccasm question
Hugo Dufort
hugo at seshat.ca
Tue Mar 10 12:05:03 EDT 2015
Re-reading the previous message and checking the code I've pasted, I
need to add a few explanations.
- There was a typo in "hhcolors", it should have been "hcolors", e.g.
the name of the globally-defined variable.
- I have added that last line ("sta hcolors") as an example of a
reference to a global variable.
- That last line was not part of the original procedure, and it gives a
"Symbol Doesn't Exist" error when compiling.
Sorry for the conflicting statements in my previous messages!
I can paste the whole code for my HSCREEN procedure here, but it's very
long and It's by no means optimized. I would like this procedure to set
global variables when it initializes the graphics port, so that other
procedures and code sections will have the chance to use these values to
make their work easier. For example, I would like to set a variable
defining the number of pixels per byte in the current graphics mode. If
I can't refer to global variables, then I will map these values to
specific (fixed) memory locations, but I prefer writing "cleaner" code.
I'm not (yet) proficient in 6809 ASM, so I'm not using all the nice
tricks, optimizations and addressing modes available.
Here is my "horrible" ASM code for HSCREEN:
=======
* procedure HSCREEN
hscreen proc width:word,height:byte,colors:byte
begin hscreen
* video mode 0xff98
ldx #$ff98
lda ,x
ora #%10000000
sta $ff98 video mode
* Video Resolution (FF99):
ldb #0 used to sum up bits
testw ldx width,u
lda colors,u
leax a,x width+colors = vidmode unique code
testw644@ cmpx #644 test width+colors
bne testw642@
orb #%11101
bra testh@
testw642@ cmpx #642
bne testw516@
orb #%10100
bra testh@
testw516@ cmpx #516
bne testw514@
orb #%11001
bra testh@
testw514@ cmpx #514
bne testw336@
orb #%10000
bra testh@
testw336@ cmpx #336
bne testw324@
orb #%11110
bra testh@
testw324@ cmpx #324
bne testw322@
orb #%10101
bra testh@
testw322@ cmpx #322
bne testw272@
orb #%01100
bra testh@
testw272@ cmpx #272
bne testw260@
orb #%11010
bra testh@
testw260@ cmpx #260
bne testw258@
orb #%10001
bra testh@
testw258@ cmpx #258
bne testw176@
orb #%01000
bra testh@
testw176@ cmpx #176
bne testh@
orb #%10110
bra testh@
* let's decode the vertical resolution (h)
testh@ lda height,u
testh192@ cmpa #192
bne testh200@
orb #%00000000
bra setmode@
testh200@ cmpa #200
bne testh225@
orb #%00100000
bra setmode@
testh225@ cmpa #225
bne setmode@
orb #%01100000
setmode@ stb $ff99 set video resolution using built mask
*vscroll register bits{0-4} - set to 0
lda #0
sta $ff9c
* init vertical offset at $60000 (D << 10 + E << 3)
addr=11000000:00000000:000, D=0110 0000, E=0000 0000
lda #192
sta $ff9d vertical offset1, bits 11-18
lda #0
sta $ff9e vertical offset2, bits 3-10
* init graphics and enable Coco3 mode
lda $ff90 init0 - load mask from memory
anda #%01111111 kills bit7 (Coco12/3 mode)
ora #%01000000 sets bit6 (MMU enable)
sta $ff90
endproc
========
Le 2015-03-10 10:29, Robert Gault a écrit :
> Hugo Dufort wrote:
>> I am using the defined variables suchas as "hwidth" to store global
>> values,
>> they're not pointers or anything else.
>>
>> I have not sent the whole HSCREEN procedure, because it is 4 pages
>> long and what
>> it does is not relevant to the question I've asked.
>>
>> There are no typos in the code. It compiles and it works just fine.
>> Right now I
>> can use my program to open any hi-res screen resolution (for example,
>> 256x225 in
>> 16 colors), draw rectangles and set pixels.
>>
>> My question only relates to acessing global variables defined here,
>> such as
>> "hwidth" or "hheight"
>>
>> Hugo
>>
>
> Hugo,
>
> Read my previous message carefully. How do you account for variables
> used in the procedure that were not defined in your message?
>
> Robert
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
>
>
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
http://www.avast.com
More information about the Coco
mailing list