Jump to content
IGNORED

ASM or bBasic?


Recommended Posts

Someone did it about 10+ years ago on the stella list, but I can't for the life of me find the post......

 

Edit: actually I'm not sure they were changing the sprites - I definitely remember a demo with a bunch of russian doll looking sprites that could be different colours, and it was done with playfield behind inverted player objects.

Edited by eshu
Link to comment
Share on other sites

I've seen that before, though I had forgotten about it. Thomas has done that trick elsewhere as well, so he's most likely where I got the idea from when I worked out my routine back in December 2010. Timing didn't quite pan out until batari suggested using the missiles and VBLANK.

 

The VBLANK trick does have a shortcoming. It looks just fine:

post-3056-0-60238200-1336834649_thumb.jpg

 

unless your display's brightness is adjusted incorrectly:

post-3056-0-74730900-1336834654_thumb.jpg

Link to comment
Share on other sites

I've got a MAME arcade in my living room

Nice. I've debated getting one, but never did.

 

the two joystick control, which can be done on the 2600 by clamping joysticks to the table

Yep - GroovyBee's done some work on a PSX controller adaptor that uses the dual shock sticks for Robotron on the 7800. I tried out the prototype at CGE and it's part of why I now own a 7800. Still waiting on the finished adaptor though :(

 

But seeing your spacerocks100.bin, I must say, I've expected much worse for 50 sprites on half a screen.

Me too, though I suspect it's because the asteroids are so small by that point that it's able to reuse the players more than it would be possible for in Robotron.

Edited by SpiceWare
Link to comment
Share on other sites

Pretty sure Chris managed it for the score table on the title screen in Juno First.

Hmm, he used a different technique - he's got both players set for 2 copies, one near and one far. He also uses the missiles to display the periods:

post-3056-0-75109500-1336835648_thumb.png

 

with the playfield to hide the initial copy of each missile.

post-3056-0-53314200-1336835658_thumb.png

Link to comment
Share on other sites

Yep - GroovyBee's done some work on a PSX controller adaptor that uses the dual shock sticks for Robotron on the 7800. I tried out the prototype at CGE and it's part of why I now own a 7800. Still waiting on the finished adaptor though :(

 

Unfortunately XM and games have taken a lot of my development time between CGE2010 and now. I'm fully intending to go back to the PSX interface when I've taken a few more projects off my WIP list.

Link to comment
Share on other sites

Unfortunately XM and games have taken a lot of my development time between CGE2010 and now. I'm fully intending to go back to the PSX interface when I've taken a few more projects off my WIP list.

 

I definitely know how that goes, Chun Li has been delayed twice now. Hopefully third times the charm.

 

Will the adaptor work on the 2600 as well, or does it require something that only the 7800 provides?

Link to comment
Share on other sites

Will the adaptor work on the 2600 as well, or does it require something that only the 7800 provides?

 

It should work fine but the current design would have problems on something like the C64 due to the way that the C64 accesses its joystick interface. Fixing that and making it programmable (buttons assigned by the player) were the two things I wanted to address in the next version. I was also toying with the idea of adding "full access mode" where you could put it in a mode where your game code could read all the buttons and stick positions (using a simple serial interface like the NES uses) and not just the buttons/sticks assigned to directions and fire by the player. However I'm not sure how useful that would be in the 2600/7800 scene or whether or not it would be supported by any developer on any platform. So that is not a definite feature at the moment.

Link to comment
Share on other sites

Pretty sure Chris managed it for the score table on the title screen in Juno First.

Hmm, he used a different technique - he's got both players set for 2 copies, one near and one far. He also uses the missiles to display the periods:

post-3056-0-75109500-1336835648_thumb.png

 

with the playfield to hide the initial copy of each missile.

post-3056-0-53314200-1336835658_thumb.png

 

Star Castle features 48 pixel and 96 pixel variants of this technique. Besides the title, also the AtariAge logo uses it.

 

post-27536-0-43216600-1336843562_thumb.png

 

This has fixed colors, though. There are some free cycles, but it looks like they are not enough to change COLUBK and COLUPF every line.

 

For a text display like the Space Rocks option screen, it would probably be possible to unroll the loop, read the data from a RAM buffer and update the buffer between text lines (if you have enough free RAM/ROM i.e.).

Edited by Joe Musashi
Link to comment
Share on other sites

It's done by using inverse graphics - the sprites are black and the color comes from the background and the playfield/ball. VBLANK is turned on/off so that the color of the playfield doesn't show on either side of the 48 pixels. VBLANK can't be changed at the exact cycle it needs to be, so the missiles are used to help hide the background on both sides of the 48 pixels.

 

 

Using Vblank is a very good idea. I was inspired by your kernel and made one that can use any background color, and no Hmove lines. Move the joystick left or right to adjust the second color. I am using an unrolled kernel with a lot of Absolute,Y addressing. Maybe DPC+ could probably be used here and get it all in a loop. Anyhow, nice kernel Spice. :)

 

48_bits_2_colors.zip

Edited by Omegamatrix
  • Like 2
Link to comment
Share on other sites

NIcely done!

 

My original kernel was for a game that also had 3 voice DPC+ music going. 3 voice music requires VOL0 to be updated every scanline so there's an additional LDA/STA that's currently replaced by a SLEEP 5. I might be able to remove the black VBLANK bars on mine if I decide to not add DPC+ music to Space Rock's or Frantic's menu.

Link to comment
Share on other sites

NIcely done!

 

My original kernel was for a game that also had 3 voice DPC+ music going. 3 voice music requires VOL0 to be updated every scanline so there's an additional LDA/STA that's currently replaced by a SLEEP 5. I might be able to remove the black VBLANK bars on mine if I decide to not add DPC+ music to Space Rock's or Frantic's menu.

 

Glad you liked it. I have done a new version that is now using scrolling colors and (indirect),Y addressing. I have it all in a subroutine. It takes 5 lines to update in between the displays.

 

post-7074-0-22761700-1336981721_thumb.png

 

48_bits_2_colors(v2).zip

 

 

 

I am loading digit 6 (the one usually loaded with Y), directly into ram. This saves a lot of cycles. I used these cycles to change the color line by line, and added the (indirect),Y addressing to gain better re-usability. Positioning is being done mid-line with cycle 74 Hmoves to hide the comb. The colors are being loaded into ram, and that could definitely be done better in DPC+ I think.

 

 

 

In the demo pressing fire selects the different text displays. The top color bar will change to the color of that display, and show the place the new color starts. Press left or right to change the position.

 

Maybe some of this demo will help you get those sounds and also no Vblank lines, Spice. There has to be a way to have your cake, and eat it too!! :)

  • Like 5
Link to comment
Share on other sites

On 5/14/2012 at 2:59 AM, Omegamatrix said:

Maybe some of this demo will help you get those sounds and also no Vblank lines, Spice. There has to be a way to have your cake, and eat it too!! :)

 

Thanks for the inspiration! I got this working last night. Just need to add a few inits to clear up the garbage at the top and by the last score, as well as swap the background & playfield colors in the datastreams, but those are minor:

post-3056-0-25207200-1337095797_thumb.png

 

ShowTwoColorGraphic:
	sty ScoreKernelCounter

S2CGloop:  
	sta WSYNC
	SLEEP 5		 ; 5  5 - time for DPC+ music audio update
	lda #<DF2DATA   ; 2  7
	sta GRP0		; 3 10
	lda #<DF3DATA   ; 2 12
	sta GRP1		; 3 15
	lda #<DF4DATA   ; 2 17
	sta GRP0		; 3 20
	ldx DF6DATA	 ; 4 24
	ldy DF7DATA	 ; 4 28
	lda #<DF1DATA   ; 2 30
	sta.w COLUPF	; 4 34
	lda #<DF1DATA   ; 2 36
	sta COLUBK	  ; 3 39  
	lda #<DF5DATA   ; 2 41
	sta GRP1		; 3 44
	stx GRP0		; 3 47
	sty GRP1		; 3 50
	sty GRP0		; 3 53
	ldx #0		  ; 2 55
	stx COLUBK	  ; 3 58
	stx COLUPF	  ; 3 61
	dec ScoreKernelCounter  ; 5 66
	bne S2CGloop	; 3 69
	rts		 ; 6 74	
 

 

Dont know if you're familiar with the DPC+ datastreams. They're DFxDATA and each access returns the next value in the datastream. I have the FASTFETCH turned on which overrides LDA #. This lets us read a datastream in 2 cycles by using LDA #<DF2DATA instead of 4 cycles when using LDA DF2DATA.

 

DF0DATA (not shown in snippet) holds the datastream that controls the menu display loop(it holds all the init values for prepping the other 7 datastreams, along with control of optional extra scanlines after a menu option as well as triggers end-of-menu).

DF1DATA holds the colors for each scanline

DF2DATA is the first 8 pixels

...

DF7DATA is the last 8 pixels.

Link to comment
Share on other sites

Glad you got it working. I'm really looking forward to Space Rocks. :)

 

You have a ton of time left in your loop to. Excluding the SLEEP cycles, you have 8 cycles left over. Might be enough time change the shape of the play field, move the ball, etc... To generate some extra effects. Supercat used the ball to make a shine effect in Stratogems. You can also make some arrow shapes pretty easily.

 

You can also gain another cycle and save a ram location. I'm not at home so I can't post some code at the moment, but last night I was playing around with using the timer as my loop counter as it decrements on its own. Since you are not indexing with Y and you are branching on BNE this could work well for you.

 

I made a test program to see what values the timer gives when it is read at 76 cycle intervals. I wanted to break the loop at zero. I found by using TIM1T I could do a maximum of 64 loops. All you have to do is figure out what value to initially put in the timer at what cycle before the loop starts.

 

Ultimately I wanted to shift my data around to take advantage of the known values the of the timer so I could skip the decrement and load, and just load (taking four cycles only).

 

Another technique for a natural decrement is storing one of the digits in ram and using PLA. At the end of the loop use TSX to reload X, and break the loop... I don't recall ATM if I got this working, i think the stack pointer goes from $ff to 0, and you branch on BMI or BNE. I'll look later.

 

Unrelated, TIM1T can also be used as a temp ram if the number of cycles between store and load is known.

  • Like 1
Link to comment
Share on other sites

Here is a small test program I made to read values from the timer. INTIM is being read once every 76 cycles in the loop, and those values are getting stored in zero page ram.

 

Ram 80 is the final value read from INTIM. It is always zero, as that is where we want to break the loop. Ram 81 is the second last value, Ram 82 the third last value, and all the way up to the LOOP_COUNT value. You can shorten the LOOP_COUNT value in the assembly file, but 64 is the maximum you can do. Read the values in Stella's Debugger.

 

Ram $FF holds the initial value loaded into the timer. When LOOP_COUNT is set to 64, 0 is the value that gets stored to $FF.

 

Currently the instruction "sta TIM1T" starts after the WSYNC. To adjust this to a different cycle, take the the value from $FF for the loop count you want. This is a base value you will use. Next for every cycle you want to delay the "sta TIM1T" subtract 1 from the base value. Now you have the new value to load into the timer when you move the instruction.

 

testIntim.zip

 

 

 

By analysis the values loaded from the timer could be used for (indirect),Y loading if the data is arranged carefully. There is a problem though in that one of the early values is $F8, and that would cause page wrapping for a number (0-9 possible) display. However you can get a scanline height of 8 or 9 no problem. If you are loading a six byte display of some graphics you could probably get a height of 36 lines, before you hit another bad value of $FC.

 

I love the harmony of the numbers. Look how nicely they line up in hex. The least significant number goes 0, C, 8, 4 before repeating over and over:

 

post-7074-0-87875200-1337148946_thumb.png

 

 

In my earlier post I was talking about storing a digit in ram, using PLA, and then TSX to have a loop with Absolute,X indexing. Now I remember the problem I encountered was wraparound adding extra cycles.

Link to comment
Share on other sites

Got to thinking that using TIM64T would probably work better. Set it to any value (0-255) then do a BIT TIMINT to test if it counted down. Using BIT means you won't trash the A, X and Y registers, which might be useful.

 

 LDX #(8*76/64) ; 2 72
 STX TIM64T     ; 4 76
Loop:
 ;69 cycles of Kernel Code
 BIT TIMINT     ; 4 73
 BPL Loop	 ; 3 76 - make sure no page break between here and Loop

 

I think that should loop for 8 scanlines, though it might be off by one. If so, try LDX #(8*76/64)-1.

 

LINES*76/64 lets you loop for 1-215 scanlines. If the -1 is needed then the range would be 1-216.

Edited by SpiceWare
Link to comment
Share on other sites

For your kernel BIT would be a good choice. :) I seem to remember trying to use TIM64T before, and then loading INTIM as my Y index, but it didn't do enough lines. 76 - 64 = 12, and 76 / 12 = 6.333 lines. I couldn't quite make the loop of 8 lines height.

 

So I am playing around with TIM1T. I'm trying to do something a little different then your routine Spice, as i would like to be able to implement this in a standard 48 bit display routine using (indirect),Y addressing. When the timer runs out on any mode it will revert back to decrementing once per cycle, so TIM1T seemed like a good fit. I'm hoping to find a way to replace:

 

dec loopcount

ldy loopcount

bpl .loopAgain

 

With:

 

ldy INTIM

bne .loopAgain

 

This would save 4 cycles in the standard 48 bit display loop, and can be made to work if the data is arranged beforehand to use the known values INTIM will give.

 

You've given me another idea though. I haven't tried TIM8T yet. It might be very good for data spacing as 76 / 8 = 9.5. This is more workable as you could have stacks of of data spaced 10 bytes apart. 1 byte would be a waste, 9 usable. I will try this later when I get home. No emulator Stella on the iPad.:(

 

I also was looking at a 7 full sized byte display I wrote a few years ago. It would be a good candidate for DPC+ optimization if I ever do a DPC kernel. :)

  • Like 1
Link to comment
Share on other sites

It works!!

 

I've successfully gotten a routine running. I laid out graphics for digits 0-8 from $FE00 to $FE4B, and graphics for digit 9 & letters A-H from $FE4C to $FE97. You can add more very easily. I was too tired to do this for the demo, but you will get the idea. I am only doing a loop of 8 scanlines in height, but you can do more. I layed it out as bunch of equates to make it easier to read. I'll see what you guys think. Macro's would be a good idea as well as a command line utility as Spiceware suggested.

 

This saves 4 cycles, and a zero page ram location over a regular 48 bit display.

 

In the demo the top numbers are generated by a standard 48 bit display, and the bottom numbers are done by the faster (uses less cycles) 48 bit routine.

 

 

 

post-7074-0-22437500-1337241486_thumb.png

 

testTIM8T.zip

  • Like 3
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...