Jump to content
  • entries
    62
  • comments
    464
  • views
    86,850

YASK: Yet Another Sudoku Kernel


supercat

904 views

A year ago, I created a kernel to display 13 characters per line, each of which could independently be one of two colors. Rather a neat trick, but it required a bunch of straight-line code. The only way to change the contents of a line of text was to modify the code that displayed it. On a SuperCharger, that could work, though displaying eight lines of text would use up most of the RAM; I dismissed the kernel as an interesting curiosity.

 

Discussions of Sudoku led me to wonder whether the kernel technique I used there could be used without RAM expansion if it didn't have to show so many characters. It turns out that it is.

 

Thus, my flicker-free Sudoku kernel demo. The cursor flickers in a crude effort to make it transparent, but otherwise no fliker is necessary. Each cell may be independently colored white or purple using the RESET button, and each cell's content may be changed using the fire button. There are no palette restrictions.

 

Can anyone explain how this works?

5 Comments


Recommended Comments

Can anyone explain how this works?

It looks like a variant of the Video Chess kernel. Is there more to it than that?

Link to comment
It looks like a variant of the Video Chess kernel. Is there more to it than that?

 

It uses some similar principes, but there's a lot more to it. The video chess kernel only has to do three writes after the first item appears, so if desired everything could be loaded into A, X, and Y or A, X, and S. The timing might be workable to include the color changes while showing five items on a line instead of four; I've not worked out whether that can be done without self-modifying code. My guess is that it could probably be done without too much difficulty if no space was left for the board's dividing lines. Providing for those, however, would probably require that the two colors be chosen such that, when ANDed together, they yielded zero.

 

In this Sudoku kernel demo, the spacing of the sprites is a bit wider than with the chess kernel, and there are no color restrictions. My next challenge is to make it work without having to use the playfield to hide some 'extra' sprites.

Link to comment

In this Sudoku kernel demo, the spacing of the sprites is a bit wider than with the chess kernel, and there are no color restrictions. My next challenge is to make it work without having to use the playfield to hide some 'extra' sprites.

I see. There are apparently 40 pixels between sprites. (I assume P0 and P1 are staggered.) That strongly suggests that you are using the multisprite trick. The 40 pixels give you about 13 cycles to update the TIA. Since there are at most five numerals per line, you can easily set the first two, and then maybe update the colors and shapes like so:

 

Let A, X, and Y be the shapes of the remaining three pieces.

sta GRP0; 3	
lda color3 ; 6
sta COLUP0 ; 9
sta.w RESP0; 13

stx GRP1  
lda color4 
sta COLUP1
sta.w RESP1

sty GRP0
lda color5
sta COLOP0
sta.w RESP0

Link to comment
I see. There are apparently 40 pixels between sprites...

 

The sprites on a line are 24 pixels apart. You are correct about using the multisprite (Galaxians) trick. The digits are 6 pixels wide for the same reason that the Galaxians in formation are. I got the thing to work without any "extra" sprites appearing, but the code bloated. I then shaved a few cycles back off so I could un-bloat the code. The present code stores the grid using 54 bytes. I think I'll rework it to use the top 5 bits of 81 bytes, since I have some plans for the other three bits. Too bad the 6507 can't handle 9-bit bytes--it would make some things so much more convenient. :D

Link to comment
Guest
Add a comment...

×   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...