Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Multiplexing sprites?
2016-06-02 19:02
Rudi
Account closed

Registered: May 2010
Posts: 125
Multiplexing sprites?

Hi,
Thanks for all the help ive gotten so far here on csdb.
Now I've runned into another problem.
How the *** does sprite multiplexing work?
I just need the basic idea. I tried to read Cadaver and other tuts, but they seemed too advanced for my taste in continuing.

What my goal is basically to display 64 sprites that stands still. So it will display a checkerboard, hence the sprites only need one of two colors. and they are filled with either of the color. The sprites are displayed beneath the characters so i can either have black and white chess-pieces (using $d800) this works fine with 8 sprites! but now i need to fill the entire checkerboard.
(edit: the entire board is in singlecolor, not multicolor btw)

I have not yet figured out how it works in theory? I just need to have interrupts on each row and display the sprites.
I have a feeling it would work something like this:

01234567
12345670
01234567
12345670
01234567
12345670
01234567
12345670

sprite 0 has darkgray, sprite 1 gray color, sprite 2 darkgray, ..etc.. so it will show a checkerboard in the end..
is it as simple as just setting an interrupt and move the sprite or do one need something else to take into consideration as well?
 
... 42 posts hidden. Click here to view all posts....
 
2016-06-04 04:12
Oswald

Registered: Apr 2002
Posts: 5094
Quote: Very good!
Now here is some notes I made when developed my prototypes which might help You from here;


Chessboard:
~~~~~~~~~~~

     a     b     c     d     e     f     g     h
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |     |#####|     |#####|     |#####|     |#####|
8 |  R  |##N##|  B  |##K##|  Q  |##B##|  N  |##R##|
  |     |#####|     |#####|     |#####|     |#####|
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |#####|     |#####|     |#####|     |#####|     |
7 |##P##|  P  |##P##|  P  |##P##|  P  |##P##|  P  |
  |#####|     |#####|     |#####|     |#####|     |
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |     |#####|     |#####|     |#####|     |#####|
6 |     |#####|     |#####|     |#####|     |#####|
  |     |#####|     |#####|     |#####|     |#####|
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |#####|     |#####|     |#####|     |#####|     |
5 |#####|     |#####|     |#####|     |#####|     |
  |#####|     |#####|     |#####|     |#####|     |
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |     |#####|     |#####|     |#####|     |#####|
4 |     |#####|     |#####|     |#####|     |#####|
  |     |#####|     |#####|     |#####|     |#####|
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |#####|     |#####|     |#####|     |#####|     |
3 |#####|     |#####|     |#####|     |#####|     |
  |#####|     |#####|     |#####|     |#####|     |
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |     |#####|     |#####|     |#####|     |#####|
2 |  P  |##P##|  P  |##P##|  P  |##P##|  P  |##P##|
  |     |#####|     |#####|     |#####|     |#####|
  +-----+-----+-----+-----+-----+-----+-----+-----+
  |#####|     |#####|     |#####|     |#####|     |
1 |##R##|  N  |##B##|  K  |##Q##|  B  |##N##|  R  |
  |#####|     |#####|     |#####|     |#####|     |
  +-----+-----+-----+-----+-----+-----+-----+-----+

Piece ID:
~~~~~~~~~

White Pawn:    #%00000001
White Rook:    #%00000010
White kNight:  #%00000011
White Bishop:  #%00000100
White Queen:   #%00000101
White King:    #%00000110

Black Pawn:    #%10000001
Black Rook:    #%10000010
Black kNight:  #%10000011
Black Bishop:  #%10000100
Black Queen:   #%10000101
Black King:    #%10000110

Bit #3 signify virgin (0) or moved (1) piece.
Bit #4 Signify En Passant Candidate (1) or not (0)

Board Coordinates:
~~~~~~~~~~~~~~~~~~

  0,  1,  2,  3,  4,  5,  6,  7
  8,  9, 10, 11, 12, 13, 14, 15
 16, 17, 18, 19, 20, 21, 22, 23
 24, 25, 26, 27, 28, 29, 30, 31
 32, 33, 34, 35, 36, 37, 38, 39
 40, 41, 42, 43, 44, 45, 46, 47
 48, 49, 50, 51, 52, 53, 54, 55
 56, 57, 58, 59, 60, 61, 62, 63

Mapped to ZP adresses: $40 - $7f (0-63)


Basically both my prototyes will display the chessboards perfectly based on the pieces in those ZP address locations. From there it's easy to save/load a game, setup Challenges based on famous games etc. From here it's straight fwd. implementation of the move rules and path-checking. Then it's the AI.

And if You want to be cool, use a mouse routine to allow picking/dropping pieces ;-)


yeah its all down hill from here, thanks for doing most of it for him:)
2016-06-04 06:27
ChristopherJam

Registered: Aug 2004
Posts: 1409
Quoting TWW
Then it's the AI.


Oh, is that all? ;)
2016-06-04 06:53
Rudi
Account closed

Registered: May 2010
Posts: 125
Skate: Thats an excelent idea.

TWW: Nice description. I wasn't going to actually make a game yet, only an chess-animation for intro to a demo, or else I would never be able to make enough stuff for a demo for X. Maybe i'll be hooked and make a game afterall, haha - But who knows. I might get bored if things start to get tricky anyway.
2016-06-04 07:02
JackAsser

Registered: Jun 2002
Posts: 2014
I thought implementing the AI was the tricky part! ;)
2016-06-04 16:07
Rudi
Account closed

Registered: May 2010
Posts: 125
JackAsser: When I wrote the AI for https://sites.google.com/site/rudibstranden/projects/chess-obse.. the tricky part was the En Passant and the special cases for castling.

I guess there might be some special logical (boolean) rules from a bitboard if its set up correctly, so one can reduce code. So that it dont get too massive for 6502/6510 code.
2016-06-04 16:25
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: JackAsser: When I wrote the AI for https://sites.google.com/site/rudibstranden/projects/chess-obse.. the tricky part was the En Passant and the special cases for castling.

I guess there might be some special logical (boolean) rules from a bitboard if its set up correctly, so one can reduce code. So that it dont get too massive for 6502/6510 code.


Can imagine! :)
2016-06-04 17:42
TWW

Registered: Jul 2009
Posts: 545
Hehe Yeah sure, it's piece of cake ;-)

If You set up the Board in ZP as described above and mark the pieces With identifying bits informing if they have been moved before or not, You only need to define the rules and here are some examples for pawns and Rooks/King:

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalPawn:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RULES:
~~~~~~
Vertical+1:      Pos+8
Vertical+2:      Pos+16         <--- Only when virgin
CapDia+1:        Pos+7
CapDia+1:        Pos+9
En Passant:      Pos+7          <--- Only when adjacent to fresh pawn opponent (Pos+16)
En Passant:      Pos+9          <--- Only when adjacent to fresh pawn opponent (Pos+16)
Upgrade:         Pos = last line (0-7 / 56-63)


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalRook:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RULES:
~~~~~~
Vertical:   Pos+8 x [1-8]
Vertical:   Pos-8 x [1-8]
Horizontal: Pos+1->8
Horizontal: Pos-1->8
Castling:   Pos+2      <--- Only when K & R are virgin
Castling:   Pos-3      <--- Only when K & R are virgin

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalKing:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RULES:
~~~~~~
Pos+1 & Pos-1
pos+7 & pos-7
Pos+8 & Pos-8
pos+9 & pos-9
Castling: Pos-2          <--- Only when K & R are virgin
Castling: Pos+3          <--- Only when K & R are virgin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


Implementing this in code is not very complicated.

Then You off course need check that the slope(s) are Clear:

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two horizontal Squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HorizontalLineClearCheck:

    // Find number of squares to check
    lda OldSquare
    sec
    sbc SelectedSquare
    bcs !+
      eor #$ff
      adc #$01
!:  tax

    // Find signed parameter to use in the slope checker
    lda OldSquare
    cmp SelectedSquare
    bcc !+
    lda #$ff
    jmp CheckSlope
!:  lda #$01
    jmp CheckSlope

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two vertical squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

VerticalLineClearCheck:
    // Find number of squares between the squares (absolute)
    lda OldSquare
    sec
    sbc SelectedSquare
    bcs !+
      eor #$ff
      adc #$01
!:  lsr
    lsr
    lsr        // Divide the difference with 8
    tax

    // Find signed parameter to use in the slope checker
    lda OldSquare
    cmp SelectedSquare
    bcc !+
    lda #$f8
    jmp CheckSlope
!:  lda #$08
    jmp CheckSlope

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two diagonal squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DiagonalLineClearCheck:

    // Check if the move is left or right
    lda OldSquare
    and #%00000111
    sta $02
    lda SelectedSquare
    and #%00000111
    sec
    sbc $02
    bcs !Left+
        eor #$ff
        adc #$01
!Right:  // XPOS SelectedSquare > OldSquare
    tax  // Number of squares to check in X-REG

    // Find if move is up or down
    lda OldSquare
    cmp SelectedSquare
    bcs !RightUp+
!RightDown:
    lda #$07
    jmp CheckSlope
!RightUp:
    lda #$f7
    jmp CheckSlope

!Left:   // XPOS OldSquare > SelectedSquare
    tax  // Number of squares to check in X-REG

    // Find if move is up or down
    lda OldSquare
    cmp SelectedSquare
    bcs !LeftUp+
!LeftDown:
    lda #$09
    jmp CheckSlope
!LeftUp:
    lda #$f9
    jmp CheckSlope


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Routine for checking if squares between two points are empty
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Parameters:
//   A- $02 - Loaded with Signed byte for slopecheck:
//     #$01 - Horizontal Right
//     #$ff - Horizontal Left     
//     #$08 - Vertical Down
//     #$f8 - Vertical Up
//     #$07 - Diagonal Down-Left
//     #$09 - Diagonal Down-Right
//     #$f9 - Diagonal Up-Right
//     #$f7 - Diagonal Up-Left
//  X-Reg - Squares to check
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckSlope:
    sta $02    // Parameter = Signed number for slope check

    dex        // Decrease with one square to check
    beq !end+  // If already zero, there was no squares to check

    // Find first square to check
    lda OldSquare
    clc
    adc $02    // Skip first square since it's occupied by the piece in oldsquare
    tay

!loop:
    lda $40,y  // Fetch Square,Y
    beq !+
        sec
        rts
!:  tya
    clc
    adc $02
    tay
    dex
    bne !loop-
!end:
    clc
    rts


Also not any rocket science.

You off course need to check if target cell is legal and if it's occupied to determine legal moves (including putting onself in chess). There are also some rules in regards to stalemate situations.

Once all the rules are defined, the Next step is the AI. This is off course the most complicated but not neccessarely as the AI has to play by the same rules defined for the game. A chess game is split up into 3 parts, the opening game, mid game and end game. Opening game, one could store 3,4,5,6.. known openings and also verify there are no cheap shots by the player along the way. then mid game it's conquer the middle Field along With valuing the pieces to determine if You should capture or not/fortify. Then for end game it Depends the score if AI should try to Draw or position for chess mate. Then You can add the complexity and also plan moves Ahead (which could be set by an dificulty setting). The only real limitation here is memory whic should be no problem considering the early chess computer games and the maount of memory available there...

Perhaps this would be a good thought for the next C64 compo, to make the smartest AI for a chessgame ;-)
2016-06-04 17:57
Oswald

Registered: Apr 2002
Posts: 5094
TWW, yeah that is like a texturemap tutorial like this: well just rotate the vertices in 3d should be simple, then interpolate uv's along the edges, then across the scanline. phong should be a piece of cake after that ;)
2016-06-04 18:51
TWW

Registered: Jul 2009
Posts: 545
It been done before (like when I was born before) and in really short Versions too:

http://www.6502.org/source/games/uchess/uchess.htm

Anyhu, just wanted to give some ideas.
2016-06-05 05:49
Oswald

Registered: Apr 2002
Posts: 5094
Quote: It been done before (like when I was born before) and in really short Versions too:

http://www.6502.org/source/games/uchess/uchess.htm

Anyhu, just wanted to give some ideas.


you are way off topic with all this here.
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
chancer
Sulevi/Virtual Dreams
Guests online: 91
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Logo Graphicians
1 t0m3000  (10)
2 Sander  (9.8)
3 Mermaid  (9.5)
4 Facet  (9.4)
5 Shine  (9.4)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.051 sec.