Fairly simple Coco3 graphics project

This area for discussing Assembly language.

Fairly simple Coco3 graphics project

Postby rickadams » Wed Oct 18, 2017 5:14 pm

http://rickadams.org/downloads/test.zip

If you want to poke around in my source and look over my shoulder, I'm working on this simple Coco3 graphics program, practicing in preparation for my next project. Written in lwasm for a CocoPI but adaptable to other platforms.
rickadams
 
Posts: 3
Joined: Mon Oct 16, 2017 6:21 pm

Re: Fairly simple Coco3 graphics project

Postby ogsteviestrow » Wed Oct 18, 2017 7:26 pm

Thanks for sharing this Rick!
Steve Strowbridge aka The Original Gamer Stevie Strow
Host of CoCoTALK! the nation's leading live talk show featuring the Tandy Color Computer

ogStevieStrow@gmail.com

http://ogsteviestrow.com
http://cocotalk.live
http://imacoconut.com
http://8bit256.com
User avatar
ogsteviestrow
Site Admin
 
Posts: 55
Joined: Mon Sep 18, 2017 11:31 pm
Location: Port Saint Lucie, FL

Re: Fairly simple Coco3 graphics project

Postby Bosco » Thu Oct 19, 2017 4:17 am

Hi Rick.

Are you writing a utility for creating graphics or graphic routines for a game?
Bosco
 
Posts: 17
Joined: Tue Oct 17, 2017 1:23 pm

Re: Fairly simple Coco3 graphics project

Postby PacoOtaktay » Thu Oct 19, 2017 11:50 am

Rick,

Thank you for sharing the link to your test graphics code. Will be interesting to see how to access CoCo 3 graphics directly.
PacoOtaktay
 
Posts: 18
Joined: Mon Sep 18, 2017 11:36 pm

Re: Fairly simple Coco3 graphics project

Postby rickadams » Thu Oct 19, 2017 3:12 pm

Bosco wrote:Hi Rick.

Are you writing a utility for creating graphics or graphic routines for a game?


Basic graphics routines for a game. The program switches into a Coco3 graphics mode, clears the screen, and draws a bunch of lines.

I'll update it to the latest version tonight. I'm not sure what's out there now is the latest.

It's pretty simple stuff at this point, so this is a good chance for someone new to assembly graphics to jump in and take a peek at the code before it gets complicated.
rickadams
 
Posts: 3
Joined: Mon Oct 16, 2017 6:21 pm

Re: Fairly simple Coco3 graphics project

Postby Bosco » Thu Oct 19, 2017 4:11 pm

My game's at a fairly advanced stage but needs some rewrites to win back memory and add extra functionally, (a stock UK Dragon has only 32k, minus screen buffer etc.)

Hopefully I can return to finishing the gameplay soon. :)
Bosco
 
Posts: 17
Joined: Tue Oct 17, 2017 1:23 pm

Re: Fairly simple Coco3 graphics project

Postby nowhereman999 » Thu Oct 19, 2017 11:49 pm

Hi Rick,

I'm really glad you are back into the CoCo it is a real boost to our community! :)

Thanks for sharing your code, it's great for beginner programmers to have real world examples to learn from. Your line assembly code is very cool! I haven't followed how your code works yet but it's nice that I now have a reference if I need it. I was recently just wondering myself how to go about drawing a line from x,y to x1,y1 in assembly now I can steal your code. :) Of course the unravelled series is a great resource too. But like I said, it's great to see real world examples.

About a year ago when I got back into programming on the CoCo I had looked through a bunch of projects to figure out how the graphics is setup. It was quite a pain. That is also why I've been releasing the source code to my projects too, so others won't have to fight to find this information. You broke down the graphics setup routines nicely explaining what modes you wanted and how to set them up.

A few things you might or might not know about lwasm is that you can use binary notation in your source code. It sometimes helps when you are setting up hardware bits to use binary for the Load instruction for example:
Code: Select all
Vid_Res_Reg             EQU $FF99
***********************************************************
* Set Hires Screen Resolution and the number of Colours
*
* Bit Pattern   Rows Displayed
*    x00xxxxx   192
*    x01xxxxx   200
*    x10xxxxx   *zero/infinite lines on screen (undefined)
*    x11xxxxx   225
* Bit Pattern   Bytes/Row (Graphics)
*    xxx000xx   16
*    xxx001xx   20
*    xxx010xx   32
*    xxx011xx   40
*    xxx100xx   64
*    xxx101xx   80   320 4 Colours 01
*    xxx110xx   128
*    xxx111xx   160
* Bit Pattern   Colours     Pixels/Byte
*    xxxxxx00   2           8
*    xxxxxx01   4           4
*    xxxxxx10   16          2
*    xxxxxx11   Undefined   Undefined
***********************************************************
* Most Common used settings (Uncomment the one you want to use)
*       LDA     #%00001000            * 256 x 192 x 2 Colours  requires 6,144  bytes = $1800 RAM
*       LDA     #%00101000            * 256 x 200 x 2 Colours  requires 6,400  bytes = $1900 RAM
       LDA     #%01101000            * 256 x 225 x 2 Colours  requires 7,200  bytes = $1C20 RAM
*       LDA     #%00010001            * 256 x 192 x 4 Colours  requires 12,288 bytes = $3000 RAM
*       LDA     #%00110001            * 256 x 200 x 4 Colours  requires 12,800 bytes = $3200 RAM
*       LDA     #%01110001            * 256 x 225 x 4 Colours  requires 14,400 bytes = $3840 RAM
*       LDA     #%00011010            * 256 x 192 x 16 Colours requires 24,576 bytes = $6000 RAM
*       LDA     #%00111010            * 256 x 200 x 16 Colours requires 25,600 bytes = $6400 RAM
*       LDA     #%01111010            * 256 x 225 x 16 Colours requires 28,800 bytes = $7080 RAM
*       LDA     #%00001100            * 320 x 192 x 2 Colours  requires 7,680  bytes = $1E00 RAM
*       LDA     #%00101100            * 320 x 200 x 2 Colours  requires 8,000  bytes = $1F40 RAM
*       LDA     #%01101100            * 320 x 225 x 2 Colours  requires 10,240 bytes = $2800 RAM
*       LDA     #%00010101            * 320 x 192 x 4 Colours  requires 15,360 bytes = $3C00 RAM
*       LDA     #%00110101            * 320 x 200 x 4 Colours  requires 16,000 bytes = $3E80 RAM
*       LDA     #%01110101            * 320 x 225 x 4 Colours  requires 18,000 bytes = $4650 RAM
*       LDA     #%00011110            * 320 x 192 x 16 Colours requires 30,720 bytes = $7800 RAM
*       LDA     #%00111110            * 320 x 200 x 16 Colours requires 32,00  bytes = $7D00 RAM
*       LDA     #%01111110            * 320 x 225 x 16 Colours requires 36,000 bytes = $8CA0 RAM
*       LDA     #%00010100            * 640 x 192 x 2 Colours  requires 15,360 bytes = $3C00 RAM
*       LDA     #%00110100            * 640 x 200 x 2 Colours  requires 16,000 bytes = $3E80 RAM
*       LDA     #%01110100            * 640 x 225 x 2 Colours  requires 18,000 bytes = $4650 RAM
*       LDA     #%00011101            * 640 x 192 x 4 Colours  requires 30,720 bytes = $7800 RAM
*       LDA     #%00111101            * 640 x 200 x 4 Colours  requires 32,000 bytes = $7D00 RAM
*       LDA     #%01111101            * 640 x 225 x 4 Colours  requires 36,000 bytes = $8CA0 RAM

        STA     Vid_Res_Reg

One other feature I really like with lwasm is how you don't always need to create labels to branch/jump to in your code. The use of the "greater than" > and "less than" < signs which point to an exclamation mark in your code. For example:

Code: Select all
    LDB    #30
!   STA    ,X+   * Line starts with exclamation mark (this replaces the need for a label)
    DECB
    BNE    <      * The "less than" sign tells the assembler to branch to the first line it finds above the current line that starts with an exclamation mark.

It's easier then coming up with another label especially if you are doing some small branches.

I've collected some code snippets too that others might find helpful and I'll post them here shortly.

Thanks again,
Glen
nowhereman999
 
Posts: 33
Joined: Mon Sep 18, 2017 11:43 pm

Re: Fairly simple Coco3 graphics project

Postby Bosco » Fri Oct 20, 2017 8:26 am

I've been using LWASM for a few years now and was unaware you could branch to the next/previous exclamation mark. That's so useful!

Thanks for sharing Glen. :D
Bosco
 
Posts: 17
Joined: Tue Oct 17, 2017 1:23 pm

Re: Fairly simple Coco3 graphics project

Postby nowhereman999 » Fri Oct 20, 2017 3:40 pm

Hi Bosco,

You're welcome, that's what these forum's are all about. :)

It is a really nice feature of the assembler, I only found it by looking at some body else's source code and wondered what are those "<" and ">" and "!" for? Then with a little trial and error I figured it out and now I use it all the time.

The user manual for LWASM is pretty hard for me to understand, I think William Astle should be a lawyer as it's very technical, it's kind of like reading a legal contract. I think some examples of how to use it's powerful features would be nice to have if someone is up to the challenge.

Maybe we should have a new section called using LWASM to it's full potential. Just kidding...

Cheers,
Glen
nowhereman999
 
Posts: 33
Joined: Mon Sep 18, 2017 11:43 pm

Re: Fairly simple Coco3 graphics project

Postby William Schaub » Sat Oct 21, 2017 5:48 pm

I like the idea of heavily documented and detailed graphics/sound examples. This is the sort of stuff that lead me to buy a somewhat overpriced book in search of pretty much the same thing. I haven't started doing coco3 stuff yet but I plan to and everything I can get my hands on for the coco3 will be much appreciated.

Some simple test screens for each mode would be really helpful.
William Schaub
 
Posts: 8
Joined: Mon Oct 16, 2017 9:08 pm

Next

Return to Assembly

Who is online

Users browsing this forum: No registered users and 2 guests

cron