🌞   🌛

Programming

  • I have found a better way to assemble 6502 code than Virtual 6502 Assembler. I installed DASM from the official Pi OS repository on my Raspberry Pi-400, rewrote the KickAss source code, and assembled that into a BASIC loader program. Took long, because of differing assembler directives, and a nasty typo 🤬

    screenshot of a Rasberry Pi OS desktop, running the helloworld program in a C64 emulator
  • Getting a foothold into 6502 machine language, bonus part

    The file I assembled and downloaded as a .PRG file, using the Virtual 6502 Assembler, I smart attached in the V.I.C.E. C128 emulator. I then attached an empty .D64 disk file, and used Basic 7.0 to save memory location $C000 to $C12F to a binary file, called “usrfunc04.c000”. I detached … read more

  • I had to search for a particular Commodore 128 command, and found it here, which, BTW, I typed in myself from a book, and corrected many errors in that book. It now is the definitive guide on the web for Commodore 128 retro-computer users. It is anonymous, though, since I haven’t written the book.

  • Goal for 2024, making games for the Commodore 64

    In the Commodore 64 Programmer’s Reference Guide, published by Commodore Business Machines, Inc. and Howard W. Sams & Co., Inc. in 1982, there is a chapter on programming graphics with history’s most popular retro-computer. Graphics are an essential part of computing, and … read more

  • Oh wow! I went to Github.com on my iPad, clicked on one of my repo’s, connected an USB keyboard and pressed the period key “.” 🤯

  • Doing the work, needing the tool (read: iPad Air, perhaps?)

    Here’s an exercise from the book “Programming the 6502”, 4th edition, by Rodnay Zaks. Exercise 1.12: Complete the following additions. Indicate the result, the carry C, the overflow V, and whether the result is correct or not: 10111111 (_______) 11000001 (_______) … read more

  • Getting a foothold into 6502 machine language, part 5

    I’ve rewritten the code I developed earlier and extended it into a full-fledged usr machine language routine. However, it needed testing, because of all the rewrites. So I grabbed my copy of Working Copy on my iPad and started Git-versioning both the assembly and the Basic code. It was … read more

  • Writing correct code is such a hassle, yet it has to be done to be able to run it, preferably without error in code, nor confusion in user.

    screenshot of iPad, showing the text of a C64 Basic program
  • Getting the formatting in a source code list right takes a lot of time and effort, if you’re doing it by hand. I guess I should just write about writing source code instead of showing it. Yeah, I know, the common saying is “show, don’t tell”, but showing is exhausting. Maybe I need a GitHub account.

  • Getting a foothold into 6502 machine language, part 4

    Yeah, I know, I know. I promised a completed function to test if a number is prime. However, I want to write an article a day, and there’s only so much one can code in a day. This time I used code by other programmers, because, you know, I’m a novice. I did, however, try to understand … read more

  • Reading through 6502 assembly code listings for my current article on assembly programming on the C64, I can see there’s an art to writing clear and easy-to-read code. Some are better at it than others. I suppose I should “steal” some of those practices (read: make them my own).

  • Getting a foothold into 6502 machine language, part 3

    This should get more interesting than the previous two parts. We want a usr function that tests if a number between 0 and 65535, inclusive, is a prime number. We expect an a result of this usr function either a -1 (true) or a 0 (false). I really should split this whole thing into four parts to keep … read more

  • Getting a foothold into 6502 machine language, part 2

    I mentioned in part 1 that there’s a convenient routine to convert a real number into a signed 16-bit integer. However, Basic line numbers are 16-bit unsigned numbers when parsed into Basic code. So there has to be a routine to turn a real value in fac1 into a 16-bit integer as part of the … read more

  • Getting a foothold into 6502 machine language, part 1

    It seems in Commodore Basic version 2 the preferred way to get a value into a user-defined 6502 machine language routine (and to get a value back), is the usr function. It took me some trial and error to get it to work. Luckily, Google is Your Friend, or, in my case DuckDuckGo. I also used … read more

  • Currently reading: Mapping the Commodore 64 by Sheldon Leemon 📚

    Why would you even want to use the C64, it’s an old computer? It isn’t old, it’s retro!

    book cover of Mapping the Commodore 64 by Sheldon Leemon
  • I got a taste of what it is to write a computer program on the C64 (see here and here). For now, that is enough for me, and I’ll refrain from doing any more for the Advent of Code. It’s just too hardcore for me! I need something less intimidating.

  • Advent of Code 2023, day 1, part one—Hunting down the bug

    This is a continuation of this article I wrote earlier today. There was a bug in my Basic program when calculating the value of the two-digit number: 140 p=f+10*l:sm=sm+p:print n,p,sm That should of course be: 140 p=f*10+l:sm=sm+p:print n,p,sm After rewriting the code I got this answer: 999 : … read more

  • So I wrote some Commodore 64 assembly code in Textastic on iPad, assembled in an online 6502 assembler, into a .PRG file, and loaded that into the V.I.C.E. C64 emulator. You can see the ML monitor output and the output of the program. Note that clearing the screen isn’t needed, simply:

    SYS 49176
    
    random maze machine code monitor in V.I.C.E. random maze output in V.I.C.E.
  • My code is almost twice as fast as the original Print Maze routine,

    10 printchr$(205.5+rnd(1));:goto 10
    
    0 d=205.5:fori=.to39:printchr$(d+rnd(.));:next:goto
    
    screenshot of Commodore 64 Basic code for a random maze
  • TIL: Apple tried to create their own CPU much earlier than you may know, Secret History: Apple’s first attempt at making a CPU, by RetroBytes on YouTube.