Difference between revisions of "Source Codes"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(General Notes)
(General Notes)
Line 133: Line 133:
  
 
* Memory range for programs is &0040-&a700. This avoids firmware and memory allocated by AMSDOS disc ROM.
 
* Memory range for programs is &0040-&a700. This avoids firmware and memory allocated by AMSDOS disc ROM.
 +
* Programs on cassette and disc have a header that define the load address, length and execution address.
 +
 +
In Pasmo assembler use the "end" mnemonic to define the label which is the execution address and use "--amsdos" to put an AMSDOS header on it.
 +
 
* Basic programs start at &170.
 
* Basic programs start at &170.
 
* Firmware uses interrupt mode 1 of the Z80 (interrupts jump to &0038)
 
* Firmware uses interrupt mode 1 of the Z80 (interrupts jump to &0038)
* Lowest place you can *LOAD* a binary file to with BASIC is &389 e.g.:
+
* Lowest place you can LOAD a binary file to with BASIC is &389 e.g.:
  
 
  openout"d"
 
  openout"d"
Line 155: Line 159:
 
*Screen is normally 40 crtc chars wide (CRTC R1=40), 25 crtc chars tall (CRTC R6=25). 8 scan lines per char (R9=7). Firmware functions assume this.
 
*Screen is normally 40 crtc chars wide (CRTC R1=40), 25 crtc chars tall (CRTC R6=25). 8 scan lines per char (R9=7). Firmware functions assume this.
 
*Screen is bitmapped. You must draw/erase your own sprites and text.
 
*Screen is bitmapped. You must draw/erase your own sprites and text.
 +
*Firmware refreshes the palette every 50th of a second, so you need to turn off the firmware and use the hardware directly, or set the colours using firmware.
 +
*Firmware can be "turned off", by disabling lower ROM, redirecting interrupts and not calling firmware functions.

Revision as of 08:39, 9 January 2013

This article contains source codes and programming examples. You may also have a look at


Assembler

Algorithms

CP/M

CPC Plus

Devices

File access

Floppy disk

Graphics

Interrupts

Keyboard

Other routines

Sound

Cross Development

General Notes

  • Memory range for programs is &0040-&a700. This avoids firmware and memory allocated by AMSDOS disc ROM.
  • Programs on cassette and disc have a header that define the load address, length and execution address.

In Pasmo assembler use the "end" mnemonic to define the label which is the execution address and use "--amsdos" to put an AMSDOS header on it.

  • Basic programs start at &170.
  • Firmware uses interrupt mode 1 of the Z80 (interrupts jump to &0038)
  • Lowest place you can LOAD a binary file to with BASIC is &389 e.g.:
openout"d"
memory <address>-1
closeout
load "code",<address>
call <exec>
  • Screen is normally at &c000-&ffff. (It can be changed using firmware, or using CRTC R12/R13)
  • Stack is normally at &c000 and goes down.
  • Extra registers (BC', AF', HL', DE' are reserved by the firmware). Avoid if you are using firmware functions.
  • Lower rom (containing OS) can be paged into memory between &0000-&3fff.
  • Upper rom is selectable, examples are BASIC and AMSDOS. They can be paged into memory between &c000-&ffff.
  • From basic, a game is run with:
RUN"<filename>

keep it in the safe memory ranges and it'll run from cassette and disc.

  • Screen is normally 40 crtc chars wide (CRTC R1=40), 25 crtc chars tall (CRTC R6=25). 8 scan lines per char (R9=7). Firmware functions assume this.
  • Screen is bitmapped. You must draw/erase your own sprites and text.
  • Firmware refreshes the palette every 50th of a second, so you need to turn off the firmware and use the hardware directly, or set the colours using firmware.
  • Firmware can be "turned off", by disabling lower ROM, redirecting interrupts and not calling firmware functions.