Here it is, the premiere software package for the Agave ][

Topics covering the 6502 emulator in Ranger Citadel: tutorials, specs, source code and share your work!

Moderator: Ranger Team Alpha

Post Reply
UncleSporky
Scholar
Posts: 140
Joined: April 25th, 2012, 4:21 pm

Here it is, the premiere software package for the Agave ][

Post by UncleSporky » September 23rd, 2014, 6:13 pm

General Vargas gets up from his desk and stretches. Reports from the field have been mostly quiet and routine today, so he's got a few minutes on his hands. Bored, he decides to go play the Snake game he created on the Agave ][ all those years ago. It's been like an old friend, and he's made sure to keep the computer clean and in working order.

Except today, something is wrong. A different message comes up entirely. He is initially distraught to see that his old program has been rewritten, but is curious to discover what the message on the screen entails. As he watches though, his curiosity turns to rage and then disgust.

"WOODSON! Recall Team Echo immediately, they've got a lot to answer for! God dammit..."

https://app.box.com/s/gw4x9sjhfbdmxeswtchb

(I apologize profusely for misusing the computer in the Ranger Citadel in this manner.)

User avatar
Joby
Developer
Posts: 129
Joined: February 23rd, 2012, 9:21 am
Location: Ground Zero - inXile
Contact:

Re: Here it is, the premiere software package for the Agave

Post by Joby » September 24th, 2014, 11:31 am

You're setting the bar high for others to follow. ;)

I'm a little surprised by the scan rate being so low, yet I don't see a delay built in. for text and low-res the speed was fine, but I think there needs to be an Agave ][+ that runs a bit faster for sure.
- Joby
inXile's ruthless Leader of Scripters

UncleSporky
Scholar
Posts: 140
Joined: April 25th, 2012, 4:21 pm

Re: Here it is, the premiere software package for the Agave

Post by UncleSporky » September 24th, 2014, 12:52 pm

Yeah, I was surprised at the speed too. I'm not a pro assembly programmer or anything but I don't think I did anything ridiculously slow, especially since all commands take the same number of clock cycles to execute.

I really wanted to display text with a timer counting up the number of lines drawn while drawing to a graphics page, then switch to graphics mode and reveal the picture instantly. This didn't appear to work though, when I switch from text to graphics mode the lines that had been drawn before switching are blank.

I assume if I manually drew the text and counter in graphics mode, that would let me draw to the back page and swap instantly? But drawing takes so long that doing it this way would've slowed things even more considerably.

It's surprisingly easy to make an image compatible with the computer. I made a 160x160 pic in Photoshop and posterized it to 4 colors, then opened it in Graphics Gale which is a good indexed color program for pixel art. I changed the image to 16 color, then edited the palette to move white/greys/black to corresponding positions (0, 7, 8, and 15), flipped the image upside down, and saved as a 4-bit bitmap. If you had a 160x160 hex editor you could literally see the image in it, drawn with numbers. Just had to remove its header and copied that data into the binary file.

Source:

Code: Select all

* = $7000
lda $FF02	'switch to text mode
lda $FF12	'set the active text page to 0 (not sure if necessary)
lda $FF10	'set the active graphics page to 0 (not sure if necessary)
lda #$AD	'store the lda absolute command at zero page
sta $01
lda #$74	'store the address of the start of picture data for use with command
sta $03		'(the second byte is just $00)
lda #$8D	'store the sta absolute command at zero page
sta $04
lda #$04	'store the address of monitor memory graphics for use with command
sta $06		'(the second byte is just $00)
lda #$60	'store the rts command at zero page
sta $07
write
lda text,x	'load the text character at the address where text begins
sta $0229,x	'store it in the text buffer
inx
txa
cmp #$CD	'after $CD characters have been written, the text is done
bne write
lda $FF05	'switch to graphics mode
loop
jsr $0001	'jump to zero page as a subroutine to copy pic from memory to screen
inc $02		'move to the next byte
inc $05
bne loop	'continue doing the subroutine until we've processed 256 bytes
inc $03		'move to the next chunk of bytes
inc $06
lda $06		'check the most significant byte
cmp #$36	'if we've reached $3600, we're done copying to the screen
bne loop
infinite
jmp infinite	'end the program
text
nop
'in a hex editor, delete the nop command and place text here
'store 160x160 bitmap at $7400, in order to match up with monitor memory at $0400

Formatted for http://www.masswerk.at/6502/assembler.html:

* = $7000
lda $FF02
lda $FF12
lda $FF10
lda #$AD
sta $01
lda #$74
sta $03
lda #$8D
sta $04
lda #$04
sta $06
lda #$60
sta $07
write lda text,x
sta $0229,x
inx
txa
cmp #$CD
bne write
lda $FF05
loop jsr $0001
inc $02
inc $05
bne loop
inc $03
inc $06
lda $06
cmp #$36
bne loop
infini jmp infini
text nop
Last edited by UncleSporky on September 24th, 2014, 4:02 pm, edited 2 times in total.

User avatar
Joby
Developer
Posts: 129
Joined: February 23rd, 2012, 9:21 am
Location: Ground Zero - inXile
Contact:

Re: Here it is, the premiere software package for the Agave

Post by Joby » September 24th, 2014, 2:08 pm

There's a TextOR mode, 0xFF07, that should allow you to draw hi-res but also overlay whats in the text buffer. You'd need to clear the section of hi-res data that would be the area where the text changes, but that should allow you to have a counter.

I really like how you used the zero page as a subroutine. The string copy routine I created for Wasteland Snake worked but seemed overly verbose.

Text and low-res graphics games are definitely possible, but at this speed not hi-res. I'll see about speeding that up to be a proper 1MHz computer. I think a soft switch to toggle speeds is the easiest. Agave ][gs 8-) That was a total oversight on my part. :oops:
- Joby
inXile's ruthless Leader of Scripters

UncleSporky
Scholar
Posts: 140
Joined: April 25th, 2012, 4:21 pm

Re: Here it is, the premiere software package for the Agave

Post by UncleSporky » September 24th, 2014, 2:12 pm

Joby wrote:I really like how you used the zero page as a subroutine. The string copy routine I created for Wasteland Snake worked but seemed overly verbose.
Yeah, I love doing that. Code that changes during runtime!

Here are some more Wasteland-appropriate bitmap display disks:

https://app.box.com/s/kxx6hifz3qrh74gy243b

Image

https://app.box.com/s/fk2gehmwx7v5qqs676nz

Image

Your browns look a bit muddy! :)

Image

User avatar
Joby
Developer
Posts: 129
Joined: February 23rd, 2012, 9:21 am
Location: Ground Zero - inXile
Contact:

Re: Here it is, the premiere software package for the Agave

Post by Joby » September 24th, 2014, 2:21 pm

UncleSporky wrote: Your browns look a bit muddy! :)
The wasteland is a dusty and dirty place! I'm actually making the pixels slightly transparent so the grime of the monitor comes through. Gotta keep it realistic.

Love it! Thanks for sharing the code and explaining how you got the image data in there. I REALLY want someone to find the other program so I can show how I did it. I promised myself I'd let that easter egg be secret until it's found, but I totally geeked out on the code for it and can't wait to share it. Come on people! Hunt through our source code and figure out where the other program is so I can talk about it! :mrgreen:
- Joby
inXile's ruthless Leader of Scripters

UncleSporky
Scholar
Posts: 140
Joined: April 25th, 2012, 4:21 pm

Re: Here it is, the premiere software package for the Agave

Post by UncleSporky » September 24th, 2014, 2:35 pm

Well I would be further along in the game if I didn't blow yesterday evening refreshing myself on assembly. :P

User avatar
Joby
Developer
Posts: 129
Joined: February 23rd, 2012, 9:21 am
Location: Ground Zero - inXile
Contact:

Re: Here it is, the premiere software package for the Agave

Post by Joby » September 24th, 2014, 3:36 pm

Ah! Figured out the extreme delay. Move your zero page use to $0001 or beyond and not $0000.

In the execution cycle for each frame update I have an interrupt if the computer flags itself to stop for that update cycle. Either from a BRK command or if you close it and get back to the game. However, it also interrupts if the program counter is 0. Not too sure why I put that in there. Possibly an error catcher or legacy development code. So, each time you jump to $0000 it stops that frame and then continues next Unity update frame, maybe 0.15 seconds later. That's kind of an interesting "feature". A nice cheap way to delay things. Set $0000 to NOP and $0001 RTS. JSR $0000 to slow things down. I think I'll keep that in there, that's kind of handy to leverage.

Moving off $0000 speeds things up a bit. *phew* I'll still look into speeding things up more, but it's not nearly as bad as I feared. ;)
- Joby
inXile's ruthless Leader of Scripters

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest