6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Apr 28, 2024 5:58 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Wed Jan 25, 2017 2:24 pm 
Offline

Joined: Wed Jan 18, 2017 2:12 pm
Posts: 35
Having just finished my annotation of the Supermon64 sources (see viewtopic.php?f=2&t=4385), I'm looking for suggestions about what code I should read next. A few interesting alternatives I'm aware of:

- DurexForth https://github.com/jkotlinski/durexforth
- SpeedScript https://archive.org/details/Computes_Speedscript
- Spindle (Trackmo Loader by LFT) http://www.linusakesson.net/software/spindle/v2.php
- AppleDOS code http://www.computerhistory.org/atchm/ap ... urce-code/
- Microsoft 6502 Basic http://www.pagetable.com/?p=774
- The C64 rom http://www.pagetable.com/c64rom/c64rom_en.html
- Apple I Integer Basic https://github.com/jefftranter/6502/tre ... sm/a1basic
- Price of Persia: https://github.com/jmechner/Prince-of-Persia-Apple-II
- Tiny Basic: https://github.com/jefftranter/6502/tre ... /tinybasic
- Acorn's BBC Basic: http://8bs.com/basic/basic4.htm

I'd prefer to read the code for real applications, not snippets or trivial examples. However, I've found a few things that look interesting enough that I'll make an exception:

- Stuff on Codebase64: http://codebase64.org/doku.php
- 6502 Assembly Language Subroutines by Leventhal and Seville: https://archive.org/details/6502_Assemb ... ubroutines

I've already read through the 256 byte Woz monitor. I'm not necessarily opposed to another annotation project, but after Supermon64 I could stand some "light reading", so things that already have comments are fine too.

I'd really like to look at the source for some C64 demos but I'm not aware of many that have been released. I know I could dissassemble them but I'd rather start with something that at least has labels, and preferably comments to help guide me along.

I'm primarily focused on original 6502 sources for classic computers, but I wouldn't mind looking at newer 65C02 or 65C816 sources if they are noteworthy.


Last edited by jblang on Wed Jan 25, 2017 11:35 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 25, 2017 2:45 pm 
Offline
User avatar

Joined: Wed Aug 17, 2005 12:07 am
Posts: 1207
Location: Soddy-Daisy, TN USA
One of my favorites is the source code to Prince of Persia for the Apple IIe.

https://github.com/jmechner/Prince-of-Persia-Apple-II

_________________
Cat; the other white meat.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 25, 2017 4:59 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Maybe Tom Pitman's implementation of Tiny Basic which I think uses an inner interpreter:
https://github.com/jefftranter/6502/tre ... /tinybasic
Jeff Tranter has assembled(!) some other sources nearby.

Perhaps Acorn's BBC Basic:
http://8bs.com/basic/basic4.htm


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 25, 2017 11:35 pm 
Offline

Joined: Wed Jan 18, 2017 2:12 pm
Posts: 35
Thanks for the suggestions... added them to the list.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 27, 2017 11:00 pm 
Offline
User avatar

Joined: Thu Jun 23, 2011 2:12 am
Posts: 229
Location: Rancho Cucamonga, California
There are two versions of Space Invaders for the PET: one that has graphics that look like little aliens, and starts up with a screen that shows you how to add sound to your PET.

The other one which I've always known as "space intruders" uses blocks to represent the aliens but has REALLY smooth movements because it uses the various graphics characters with different size blocks to move the aliens around. It also has a screen (written in Assembly if I remember correctly) that lets you adjust parameters (and cheat). See e.g. https://youtu.be/bNAS-fJpKaE?t=4m12s.

It only works on a PET with a v1 or v2 ROM; if you run it on a later CBM, the program stops with an error message because the BASIC part does a PEEK to check which ROM the machine has, uses the value in a calculation and then tries to poke it back, but ROMs other than the PET cause an overflow.

The machine language part of the program was hidden in some smart way: It loads from tape, but you can't see it when you do a LIST and if you try to save the program and load it back from tape, it won't work because a SAVE won't save the machine language part of the program.

I've always wondered how that program was written but right now I can't even find it online for downloading (the other Space Invaders is all over the place).

===Jac


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 28, 2017 7:44 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
Might be interesting to read this recent disassembly of Thrust (for the Beeb)
https://github.com/kieranhj/thrust-disa ... hrust.6502


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 29, 2017 8:51 am 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 672
jac_goudsmit wrote:
The machine language part of the program was hidden in some smart way: It loads from tape, but you can't see it when you do a LIST and if you try to save the program and load it back from tape, it won't work because a SAVE won't save the machine language part of the program.

I've always wondered how that program was written but right now I can't even find it online for downloading (the other Space Invaders is all over the place).


That's not any sort of special manipulation to hide it. BASIC can't list machine language, so it would just show up as garble anyway if it tried. For single-file programs, the machine code is generally just concatenated to the end of the BASIC program, and the SYS instruction should be hardcoded to wherever that happens to land.

To build it, either the assembled binary file is appended onto the end of the BASIC program file as a file operation; or the BASIC and asm portions are both loaded into memory and saved together as 1 file (after POKEing the end of BASIC listing to an exaggerated address to include the ML, or saved from a resident ML monitor); or the assembly source code included the bytes for the BASIC launcher as effectively .byte directives inline. For that era, I would suspect option #2 was the most common.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 29, 2017 4:09 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8148
Location: Midwestern USA
jac_goudsmit wrote:
The machine language part of the program was hidden in some smart way: It loads from tape, but you can't see it when you do a LIST and if you try to save the program and load it back from tape, it won't work because a SAVE won't save the machine language part of the program.

That is a common technique, in which a short piece of BASIC code says something like SYS 2063 (on the Commodore 64).

At the time when the program was created, the save was from the machine language monitor so that memory beyond the end-of-BASIC-text address was saved along with the BASIC text. When a program of any kind is LOADed with LOAD "<prog name>" (tape) or LOAD "<prog name>",8 (disk), a relocating load will occur. Once the load from tape or disk has finished, the BASIC interpreter will set its end-of-text pointer to a null that immediately follows the tokenized form of SYS 2063. This action is part of the normal linking process performed once the program has been read into memory (starting at $0800 in the Commodore 64). Due to these actions on the part of BASIC, the only thing that will be seen when the program is LISTed will be SYS 2063, even though all of the following machine code was LOADed as well. Also, as the end-of-program-text pointer points to the end of the BASIC text, not the entire program, an attempt to SAVE the program will "fail," since only the BASIC text will be saved.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 29, 2017 4:52 pm 
Offline
User avatar

Joined: Thu Jun 23, 2011 2:12 am
Posts: 229
Location: Rancho Cucamonga, California
I know how assembler programs were piggybacked to basic programs on the PET, I imagine many assembler programs were written completely in assembler and just had "org $400" (start of basic RAM on PET/CBM) followed by the bytes that represent the SYS instruction to jump into the machine language.

Space intruders (or whatever the official name is) had quite a few lines of basic preceding the ML part of the program, it wasn't just a single SYS instruction. Anyway in the days when I was interested in saving a version of the program that started with different parameters, I didn't know that "SAVE" in basic wouldn't save the machine language part, so I know I ruined someone's recording of the program at least once (sorry Mr Verschuren). Fortunately he had a backup.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 29, 2017 6:26 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1927
Location: Sacramento, CA, USA
Bob Bishop's "AppleVision" mixed a substantial amount of Integer BASIC and ML as well ... it was very clever and a bit tricky ... so tricky that I never completely understood how he did it, although I was able to track down his hi-res character generator code and use it as an inspiration for my own versions.

https://www.youtube.com/watch?v=RiWE-aO-cyU

Mike B.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: