Author Topic: C64 Programming Adventures  (Read 12198 times)

0 Members and 1 Guest are viewing this topic.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: C64 Programming Adventures
« Reply #15 on: July 10, 2014, 05:36:15 am »
According to Kiwidepia it's a 6510 at about 1MHz so I don't think it's possible. :P

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: C64 Programming Adventures
« Reply #16 on: July 10, 2014, 06:13:09 am »
And I'm not that good at 6502 assembly yet. The most complex thing I made so far is a sprite which you can move using the joystick.
If you like my work: why not give me an internet?








Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: C64 Programming Adventures
« Reply #17 on: July 10, 2014, 07:46:22 am »
Yet another member owns a commodore 64 now. I found a whole stack of commodore stuff in a thriftshop including 3 disk drives, 2 cartridges, a datasette and ofc. a commodore 64.  aeTIos came over to my place today and came to pick it up. Expect more software to be released soon!


Left: me, right: aeTIos.

That's awesome that you guys were able to meet up. ;D Congrats on getting a c64 AeTIos. ;D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: C64 Programming Adventures
« Reply #18 on: July 10, 2014, 12:23:24 pm »
And I'm not that good at 6502 assembly yet. The most complex thing I made so far is a sprite which you can move using the joystick.
would it be possible in BASIC, though, even if the game lacks scrolling and the character moves block by block like in the original 2004 game?

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: C64 Programming Adventures
« Reply #19 on: July 10, 2014, 12:48:16 pm »
Simple interrupt-driven border flasher:
Code: [Select]
setup=*
sei
lda #<intcode
sta 788
lda #>intcode
sta 789
cli
rts
intcode=*
inc $d020
jmp $ea31
Hex:
Code: [Select]
78 A9 0D 8D 14 03 A9 10
8D 15 03 58 60 EE 20 D0
4C 31 EA




Read NES controller on userport (special hardware required)
Hex only for now...
Result is stored at $0002
Code: [Select]

A9 01 85 FB A9 06 8D 03
DD A9 02 8D 01 DD A2 08
A9 00 8D 01 DD 06 02 AD
01 DD A0 04 8C 01 DD 25
FB 05 02 85 02 A0 00 8C
01 DD CA D0 E8 60
« Last Edit: July 10, 2014, 01:31:51 pm by Keoni29 »
If you like my work: why not give me an internet?








Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: C64 Programming Adventures
« Reply #20 on: July 11, 2014, 10:46:07 am »
Found an error in my c64 manual.
it tells me to type in this:

1 REM UP, UP, AND AWAY
5 PRINT "(CLR/HOME)"
10 V = 53248 : REM START OF DISPLAY CHIP
11 POKE V + 21,4 : REM ENABLE SPRITE 2
12 POKE 2042,255 : REM SPRITE 2 DATA FROM BLOCK 255
20 FOR N = 0 TO 62 : READ Q : POKE 832+N,Q : NEXT
30 FOR X = 0 TO 200     ^ GETS ITS INFO. FROM DATA
40 POKE V + 4,X : REM UPDATE X COORDINATES
50 POKE V + 5,X : REM UPDATE Y COORDINATES
60 NEXT X
70 GOTO 30
200 DATA 0,127,0,1,255,192,3,255,224,3,231,224
210 DATA 7,217,240,7,223,240,7,217,240,3,231,224
220 DATA 3,255,224,3,255,224,2,255,160,1,127,64
230 DATA 1,62,64,0,156,128,0,156,128,0,73,0,0,73,0
240 DATA 0,62,0,0,62,0,0,62,0,0,28,0


So I typed that in and got a garbled sprite. Did some research, discovered that the BLOCK should be [buffloc]/64 and thus 13, and not 255.
*phew* I thought it was broken for a sec :P
I'm not a nerd but I pretend:

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: C64 Programming Adventures
« Reply #21 on: July 12, 2014, 10:02:39 am »
Program for drawing blocks on the screen:
Code: [Select]
// Draw blocks on screen
// Author:      Koen van Vliet
// Date:      12 Jul 2014
//
// Notes:
// *   Use kickassembler to assemble

//=================================================
// B A S I C  S Y S ()
//=================================================
.pc =$0801 "Basic Upstart Program"
:BasicUpstart(main)
//=================================================
// M A I N
//=================================================
.pc = $0820
main:
      jsr $E544            // Kernal routine: Clear screen
      sei                  // Disable interrupts
      // Black block
      :fillBlock($0400,4,16,10,6,35)
      :fillBlock($D800,4,16,10,6,0)
      // Green block
      :fillBlock($0400,11,1,18,23,224)
      :fillBlock($D800,11,1,18,23,13)
      // White block
      :fillBlock($0400,16,6,20,6,0)
      :fillBlock($D800,16,6,20,6,1)
      cli                  // Enable interrupts
      rts                  // Return to Basic
//=================================================
// M A C R O 'S
//=================================================
// Routine: fillBlock
//       Fills a rectangular block in memory with one value
.macro fillBlock(base,col,row,w,h,val){
      .const addr = base + 40 * row + col - 1
      lda #<addr            // Set up parameters         
      sta mod_b_addr + 1
      lda #>addr         
      sta mod_b_addr + 2
      lda #w
      sta mod_b_w + 1
      lda #h
      sta mod_b_h + 1
      lda #val
      sta mod_b_v + 1
      jsr fill_block         // Draw a block on screen
}
//=================================================
// R O U T I N E S
//=================================================
// Routine: fill block
//       Fills a rectangular block in memory with one value
//
// Input: Modify parameters by modifying operands.
//         Preferably use the macro for this
// Output: -
// Notes:
// *   Intended for filling blocks in screen/color ram.
//      Assumes 40 bytes per row.
// *   Does not clip outside of screen area.
fill_block:
   mod_b_h:
      ldy #$08            // Operand is modified by program.
loop_row:                  // Default value given to make this
   mod_b_w:
      ldx #$08            // Operand is modified by program.
loop_col:
   mod_b_v:
      lda #224            // Fill block with single value.
   mod_b_addr:               // Operand is modified by program.
      sta $FFFF,x             // Write character to screen. Operand is
      dex                  // modified by program.
      bne loop_col

      clc
      lda #40
      adc mod_b_addr + 1      // Modify operand low byte
      sta mod_b_addr + 1
      lda #0
      adc mod_b_addr + 2      // Modify operand high byte
      sta mod_b_addr + 2

      dey
      bne loop_row
      rts


You can draw blocks at any memory location. You must specify the base address  of the ram area you want to use.
To draw a block of characters on the screen the base address is $0400
To change the color you simply fill a block in color ram. The base address for color ram is $D800
« Last Edit: July 12, 2014, 10:07:30 am by Keoni29 »
If you like my work: why not give me an internet?