<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.sizecoding.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Superogue</id>
		<title>SizeCoding - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.sizecoding.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Superogue"/>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/wiki/Special:Contributions/Superogue"/>
		<updated>2026-05-13T15:42:42Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.0</generator>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1879</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1879"/>
				<updated>2025-12-18T23:28:36Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The SEGA MegaDrive / Genesis is a 16-bit videogame console released by SEGA in 1989.&lt;br /&gt;
&lt;br /&gt;
It features:&lt;br /&gt;
* 320x240 resolution (PAL)&lt;br /&gt;
* 4x 16 color palettes&lt;br /&gt;
* Tile based display chip with 2 scrolling tilemaps&lt;br /&gt;
* 64 Sprites (up to 4x4tiles in size each)&lt;br /&gt;
* 64K of dedicated Video Memory (VRAM)&lt;br /&gt;
* YM2612 Sound Chip&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This vector table is then followed by the ROM header at 0x100&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure located at 0x100 that specifies some metadata about the ROM, like its name, author, version number, release date, region, and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Start address 	End address 	Description 	32X SH-2 address&lt;br /&gt;
$000000 	$3FFFFF 	Cartridge ROM/RAM 	$2000000-$23FFFFF&lt;br /&gt;
$400000 	$7FFFFF 	Reserved (used by the Mega-CD and 32X)&lt;br /&gt;
$800000 	$9FFFFF 	Reserved (used by the 32X)&lt;br /&gt;
$840000 	$85FFFF 	32X frame buffer 	$4000000-$401FFFF&lt;br /&gt;
$860000 	$87FFFF 	32X frame buffer overwrite mode 	$4020000-$403FFFF&lt;br /&gt;
$880000 	$8FFFFF 	32X cartridge ROM (first 512kB bank only)&lt;br /&gt;
$900000 	$9FFFFF 	32X cartridge bankswitched ROM (any 512kB bank, controlled by 32X registers)&lt;br /&gt;
$A00000 	$A0FFFF 	Z80 memory space&lt;br /&gt;
$A10000 	$A10001 	Version register&lt;br /&gt;
$A10002 	$A10003 	Controller 1 data&lt;br /&gt;
$A10004 	$A10005 	Controller 2 data&lt;br /&gt;
$A10006 	$A10007 	Expansion port data&lt;br /&gt;
$A10008 	$A10009 	Controller 1 control&lt;br /&gt;
$A1000A 	$A1000B 	Controller 2 control&lt;br /&gt;
$A1000C 	$A1000D 	Expansion port control&lt;br /&gt;
$A1000E 	$A1000F 	Controller 1 serial transmit&lt;br /&gt;
$A10010 	$A10011 	Controller 1 serial receive&lt;br /&gt;
$A10012 	$A10013 	Controller 1 serial control&lt;br /&gt;
$A10014 	$A10015 	Controller 2 serial transmit&lt;br /&gt;
$A10016 	$A10017 	Controller 2 serial receive&lt;br /&gt;
$A10018 	$A10019 	Controller 2 serial control&lt;br /&gt;
$A1001A 	$A1001B 	Expansion port serial transmit&lt;br /&gt;
$A1001C 	$A1001D 	Expansion port serial receive&lt;br /&gt;
$A1001E 	$A1001F 	Expansion port serial control&lt;br /&gt;
$A10020 	$A10FFF 	Reserved&lt;br /&gt;
$A11000 	Memory mode register&lt;br /&gt;
$A11002 	$A110FF 	Reserved&lt;br /&gt;
$A11100 	$A11101 	Z80 bus request&lt;br /&gt;
$A11102 	$A111FF 	Reserved&lt;br /&gt;
$A11200 	$A11201 	Z80 reset&lt;br /&gt;
$A11202 	$A12FFF 	Reserved&lt;br /&gt;
$A13000 	$A130FF 	TIME registers; used to send signals to the cartridge&lt;br /&gt;
$A130EC 	$A130EF 	&amp;quot;MARS&amp;quot; when 32X is attached&lt;br /&gt;
$A130F1 	SRAM access register&lt;br /&gt;
$A130F3 	Bank register for address $80000-$FFFFF&lt;br /&gt;
$A130F5 	Bank register for address $100000-$17FFFF&lt;br /&gt;
$A130F7 	Bank register for address $180000-$1FFFFF&lt;br /&gt;
$A130F9 	Bank register for address $200000-$27FFFF&lt;br /&gt;
$A130FB 	Bank register for address $280000-$2FFFFF&lt;br /&gt;
$A130FD 	Bank register for address $300000-$37FFFF&lt;br /&gt;
$A130FF 	Bank register for address $380000-$3FFFFF&lt;br /&gt;
$A14000 	$A14003 	TMSS &amp;quot;SEGA&amp;quot;&lt;br /&gt;
$A14101 	TMSS/cartridge register&lt;br /&gt;
$A14102 	$BFFFFF 	Reserved&lt;br /&gt;
$C00000 	$C00001 	VDP data port&lt;br /&gt;
$C00002 	$C00003 	VDP data port (mirror)&lt;br /&gt;
$C00004 	$C00005 	VDP control port&lt;br /&gt;
$C00006 	$C00007 	VDP control port (mirror)&lt;br /&gt;
$C00008 	$C00009 	VDP H/V counter&lt;br /&gt;
$C0000A 	$C0000F 	VDP H/V counter (mirror)&lt;br /&gt;
$C00011 	PSG output&lt;br /&gt;
$C00013 	$C00017 	PSG output (mirror)&lt;br /&gt;
$C0001C 	$C0001D 	Debug register&lt;br /&gt;
$C0001E 	$C0001F 	Debug register (mirror)&lt;br /&gt;
$C00020 	$FEFFFF 	Reserved&lt;br /&gt;
$FF0000 	$FFFFFF 	68000 RAM &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Startup ===&lt;br /&gt;
From here it jumps to the CPU entry point and we need to the minimum startup here:&lt;br /&gt;
The MegaDrive in Supervisor mode already.&lt;br /&gt;
&lt;br /&gt;
The TMSS ROM does is place the SEGA text on screen and run a timer, then I think it just unmaps itself from the address space and does a soft reset. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #'SEGA', ($A14000) ; disable TMSS so that accessing the VDP won't lock up the console&lt;br /&gt;
tst.w ($C00004)    ; test VDP CONTROL to stop the VDP, this makes it discard anything that was previously in the FIFO&lt;br /&gt;
move.w #$2700, sr ; set IPL level 7&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This setup should give you fully predictable state on every power cycle or reset&lt;br /&gt;
that's just to play it safe, but getting a spurious interrupt before you even have the chance to disable interrupt processing is pretty much impossible in the real world&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
So after the TMSS boot sequence you'll have a black screen but some leftover stuff in VRAM&lt;br /&gt;
You'll have to enable display which you already need to to when setting the VDP registers to your desired configuration And no, the TMSS ROM doesn't use any interrupts&lt;br /&gt;
It doesn't even use DMA, the 68k copies all the graphics and all.&lt;br /&gt;
&lt;br /&gt;
The VDP always initializes to 320x224, to get 320x240 you have to enable V30 mode&lt;br /&gt;
that's why sonic 1 on PAL has borders at the top and bottom they didn't care to change the video height, and PAL systems have a smaller window for 320x224.&lt;br /&gt;
&lt;br /&gt;
==== VDP Setup ====&lt;br /&gt;
VDP Access is handled by the following 3 ports and VDP Register constants:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
VdpCtrl:    equ $C00004  ; VDP control port&lt;br /&gt;
VdpData:    equ $C00000  ; VDP data port&lt;br /&gt;
HvCounter:  equ $C00008  ; H/V counter&lt;br /&gt;
&lt;br /&gt;
VDPREG_MODE1:     equ $8000  ; Mode register #1&lt;br /&gt;
VDPREG_MODE2:     equ $8100  ; Mode register #2&lt;br /&gt;
VDPREG_MODE3:     equ $8B00  ; Mode register #3&lt;br /&gt;
VDPREG_MODE4:     equ $8C00  ; Mode register #4&lt;br /&gt;
&lt;br /&gt;
VDPREG_PLANEA:    equ $8200  ; Plane A table address&lt;br /&gt;
VDPREG_PLANEB:    equ $8400  ; Plane B table address&lt;br /&gt;
VDPREG_SPRITE:    equ $8500  ; Sprite table address&lt;br /&gt;
VDPREG_WINDOW:    equ $8300  ; Window table address&lt;br /&gt;
VDPREG_HSCROLL:   equ $8D00  ; HScroll table address&lt;br /&gt;
&lt;br /&gt;
VDPREG_SIZE:      equ $9000  ; Plane A and B size&lt;br /&gt;
VDPREG_WINX:      equ $9100  ; Window X split position&lt;br /&gt;
VDPREG_WINY:      equ $9200  ; Window Y split position&lt;br /&gt;
VDPREG_INCR:      equ $8F00  ; Autoincrement&lt;br /&gt;
VDPREG_BGCOL:     equ $8700  ; Background color&lt;br /&gt;
VDPREG_HRATE:     equ $8A00  ; HBlank interrupt rate&lt;br /&gt;
&lt;br /&gt;
VDPREG_DMALEN_L:  equ $9300  ; DMA length (low)&lt;br /&gt;
VDPREG_DMALEN_H:  equ $9400  ; DMA length (high)&lt;br /&gt;
VDPREG_DMASRC_L:  equ $9500  ; DMA source (low)&lt;br /&gt;
VDPREG_DMASRC_M:  equ $9600  ; DMA source (mid)&lt;br /&gt;
VDPREG_DMASRC_H:  equ $9700  ; DMA source (high)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A somewhat limited VDP setup can look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
   lea     (VdpCtrl), a0 &lt;br /&gt;
    move.w  #VDPREG_MODE1|$04, (a0)    ; Mode register #1&lt;br /&gt;
    move.w  #VDPREG_MODE2|$04, (a0)    ; Mode register #2&lt;br /&gt;
    move.w  #VDPREG_MODE3|$00, (a0)    ; Mode register #3&lt;br /&gt;
    move.w  #VDPREG_MODE4|$81, (a0)    ; Mode register #4&lt;br /&gt;
    &lt;br /&gt;
    move.w  #VDPREG_PLANEA|$30, (a0)   ; Plane A address&lt;br /&gt;
    move.w  #VDPREG_PLANEB|$07, (a0)   ; Plane B address&lt;br /&gt;
    move.w  #VDPREG_SPRITE|$78, (a0)   ; Sprite address&lt;br /&gt;
    move.w  #VDPREG_WINDOW|$34, (a0)   ; Window address&lt;br /&gt;
    move.w  #VDPREG_HSCROLL|$3D, (a0)  ; HScroll address&lt;br /&gt;
    &lt;br /&gt;
    move.w  #VDPREG_SIZE|$01, (a0)     ; Tilemap size&lt;br /&gt;
    move.w  #VDPREG_WINX|$00, (a0)     ; Window X split&lt;br /&gt;
    move.w  #VDPREG_WINY|$00, (a0)     ; Window Y split&lt;br /&gt;
    move.w  #VDPREG_INCR|$02, (a0)     ; Autoincrement&lt;br /&gt;
    move.w  #VDPREG_BGCOL|$00, (a0)    ; Background color&lt;br /&gt;
    move.w  #VDPREG_HRATE|$FF, (a0)    ; HBlank IRQ rate&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information, check out https://plutiedev.com/vdp-setup&lt;br /&gt;
&lt;br /&gt;
==== VDP Register ====&lt;br /&gt;
Here is a detailed explaination of the different VDP registers:&lt;br /&gt;
https://plutiedev.com/vdp-registers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1878</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1878"/>
				<updated>2025-12-18T23:25:28Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The SEGA MegaDrive / Genesis is a 16-bit videogame console released by SEGA in 1989.&lt;br /&gt;
&lt;br /&gt;
It features:&lt;br /&gt;
* 320x240 resolution (PAL)&lt;br /&gt;
* 4x 16 color palettes&lt;br /&gt;
* Tile based display chip with 2 scrolling tilemaps&lt;br /&gt;
* 64 Sprites (up to 4x4tiles in size each)&lt;br /&gt;
* 64K of dedicated Video Memory (VRAM)&lt;br /&gt;
* YM2612 Sound Chip&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This vector table is then followed by the ROM header at 0x100&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure located at 0x100 that specifies some metadata about the ROM, like its name, author, version number, release date, region, and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Start address 	End address 	Description 	32X SH-2 address&lt;br /&gt;
$000000 	$3FFFFF 	Cartridge ROM/RAM 	$2000000-$23FFFFF&lt;br /&gt;
$400000 	$7FFFFF 	Reserved (used by the Mega-CD and 32X)&lt;br /&gt;
$800000 	$9FFFFF 	Reserved (used by the 32X)&lt;br /&gt;
$840000 	$85FFFF 	32X frame buffer 	$4000000-$401FFFF&lt;br /&gt;
$860000 	$87FFFF 	32X frame buffer overwrite mode 	$4020000-$403FFFF&lt;br /&gt;
$880000 	$8FFFFF 	32X cartridge ROM (first 512kB bank only)&lt;br /&gt;
$900000 	$9FFFFF 	32X cartridge bankswitched ROM (any 512kB bank, controlled by 32X registers)&lt;br /&gt;
$A00000 	$A0FFFF 	Z80 memory space&lt;br /&gt;
$A10000 	$A10001 	Version register&lt;br /&gt;
$A10002 	$A10003 	Controller 1 data&lt;br /&gt;
$A10004 	$A10005 	Controller 2 data&lt;br /&gt;
$A10006 	$A10007 	Expansion port data&lt;br /&gt;
$A10008 	$A10009 	Controller 1 control&lt;br /&gt;
$A1000A 	$A1000B 	Controller 2 control&lt;br /&gt;
$A1000C 	$A1000D 	Expansion port control&lt;br /&gt;
$A1000E 	$A1000F 	Controller 1 serial transmit&lt;br /&gt;
$A10010 	$A10011 	Controller 1 serial receive&lt;br /&gt;
$A10012 	$A10013 	Controller 1 serial control&lt;br /&gt;
$A10014 	$A10015 	Controller 2 serial transmit&lt;br /&gt;
$A10016 	$A10017 	Controller 2 serial receive&lt;br /&gt;
$A10018 	$A10019 	Controller 2 serial control&lt;br /&gt;
$A1001A 	$A1001B 	Expansion port serial transmit&lt;br /&gt;
$A1001C 	$A1001D 	Expansion port serial receive&lt;br /&gt;
$A1001E 	$A1001F 	Expansion port serial control&lt;br /&gt;
$A10020 	$A10FFF 	Reserved&lt;br /&gt;
$A11000 	Memory mode register&lt;br /&gt;
$A11002 	$A110FF 	Reserved&lt;br /&gt;
$A11100 	$A11101 	Z80 bus request&lt;br /&gt;
$A11102 	$A111FF 	Reserved&lt;br /&gt;
$A11200 	$A11201 	Z80 reset&lt;br /&gt;
$A11202 	$A12FFF 	Reserved&lt;br /&gt;
$A13000 	$A130FF 	TIME registers; used to send signals to the cartridge&lt;br /&gt;
$A130EC 	$A130EF 	&amp;quot;MARS&amp;quot; when 32X is attached&lt;br /&gt;
$A130F1 	SRAM access register&lt;br /&gt;
$A130F3 	Bank register for address $80000-$FFFFF&lt;br /&gt;
$A130F5 	Bank register for address $100000-$17FFFF&lt;br /&gt;
$A130F7 	Bank register for address $180000-$1FFFFF&lt;br /&gt;
$A130F9 	Bank register for address $200000-$27FFFF&lt;br /&gt;
$A130FB 	Bank register for address $280000-$2FFFFF&lt;br /&gt;
$A130FD 	Bank register for address $300000-$37FFFF&lt;br /&gt;
$A130FF 	Bank register for address $380000-$3FFFFF&lt;br /&gt;
$A14000 	$A14003 	TMSS &amp;quot;SEGA&amp;quot;&lt;br /&gt;
$A14101 	TMSS/cartridge register&lt;br /&gt;
$A14102 	$BFFFFF 	Reserved&lt;br /&gt;
$C00000 	$C00001 	VDP data port&lt;br /&gt;
$C00002 	$C00003 	VDP data port (mirror)&lt;br /&gt;
$C00004 	$C00005 	VDP control port&lt;br /&gt;
$C00006 	$C00007 	VDP control port (mirror)&lt;br /&gt;
$C00008 	$C00009 	VDP H/V counter&lt;br /&gt;
$C0000A 	$C0000F 	VDP H/V counter (mirror)&lt;br /&gt;
$C00011 	PSG output&lt;br /&gt;
$C00013 	$C00017 	PSG output (mirror)&lt;br /&gt;
$C0001C 	$C0001D 	Debug register&lt;br /&gt;
$C0001E 	$C0001F 	Debug register (mirror)&lt;br /&gt;
$C00020 	$FEFFFF 	Reserved&lt;br /&gt;
$FF0000 	$FFFFFF 	68000 RAM &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Startup ===&lt;br /&gt;
From here it jumps to the CPU entry point and we need to the minimum startup here:&lt;br /&gt;
The MegaDrive in Supervisor mode already.&lt;br /&gt;
&lt;br /&gt;
The TMSS ROM does is place the SEGA text on screen and run a timer, then I think it just unmaps itself from the address space and does a soft reset. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #'SEGA', ($A14000) ; disable TMSS so that accessing the VDP won't lock up the console&lt;br /&gt;
tst.w ($C00004)    ; test VDP CONTROL to stop the VDP, this makes it discard anything that was previously in the FIFO&lt;br /&gt;
move.w #$2700, sr ; set IPL level 7&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This setup should give you fully predictable state on every power cycle or reset&lt;br /&gt;
that's just to play it safe, but getting a spurious interrupt before you even have the chance to disable interrupt processing is pretty much impossible in the real world&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
So after the TMSS boot sequence you'll have a black screen but some leftover stuff in VRAM&lt;br /&gt;
You'll have to enable display which you already need to to when setting the VDP registers to your desired configuration And no, the TMSS ROM doesn't use any interrupts&lt;br /&gt;
It doesn't even use DMA, the 68k copies all the graphics and all&lt;br /&gt;
&lt;br /&gt;
==== VDP Setup ====&lt;br /&gt;
VDP Access is handled by the following 3 ports and VDP Register constants:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
VdpCtrl:    equ $C00004  ; VDP control port&lt;br /&gt;
VdpData:    equ $C00000  ; VDP data port&lt;br /&gt;
HvCounter:  equ $C00008  ; H/V counter&lt;br /&gt;
&lt;br /&gt;
VDPREG_MODE1:     equ $8000  ; Mode register #1&lt;br /&gt;
VDPREG_MODE2:     equ $8100  ; Mode register #2&lt;br /&gt;
VDPREG_MODE3:     equ $8B00  ; Mode register #3&lt;br /&gt;
VDPREG_MODE4:     equ $8C00  ; Mode register #4&lt;br /&gt;
&lt;br /&gt;
VDPREG_PLANEA:    equ $8200  ; Plane A table address&lt;br /&gt;
VDPREG_PLANEB:    equ $8400  ; Plane B table address&lt;br /&gt;
VDPREG_SPRITE:    equ $8500  ; Sprite table address&lt;br /&gt;
VDPREG_WINDOW:    equ $8300  ; Window table address&lt;br /&gt;
VDPREG_HSCROLL:   equ $8D00  ; HScroll table address&lt;br /&gt;
&lt;br /&gt;
VDPREG_SIZE:      equ $9000  ; Plane A and B size&lt;br /&gt;
VDPREG_WINX:      equ $9100  ; Window X split position&lt;br /&gt;
VDPREG_WINY:      equ $9200  ; Window Y split position&lt;br /&gt;
VDPREG_INCR:      equ $8F00  ; Autoincrement&lt;br /&gt;
VDPREG_BGCOL:     equ $8700  ; Background color&lt;br /&gt;
VDPREG_HRATE:     equ $8A00  ; HBlank interrupt rate&lt;br /&gt;
&lt;br /&gt;
VDPREG_DMALEN_L:  equ $9300  ; DMA length (low)&lt;br /&gt;
VDPREG_DMALEN_H:  equ $9400  ; DMA length (high)&lt;br /&gt;
VDPREG_DMASRC_L:  equ $9500  ; DMA source (low)&lt;br /&gt;
VDPREG_DMASRC_M:  equ $9600  ; DMA source (mid)&lt;br /&gt;
VDPREG_DMASRC_H:  equ $9700  ; DMA source (high)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A somewhat limited VDP setup can look something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
   lea     (VdpCtrl), a0 &lt;br /&gt;
    move.w  #VDPREG_MODE1|$04, (a0)    ; Mode register #1&lt;br /&gt;
    move.w  #VDPREG_MODE2|$04, (a0)    ; Mode register #2&lt;br /&gt;
    move.w  #VDPREG_MODE3|$00, (a0)    ; Mode register #3&lt;br /&gt;
    move.w  #VDPREG_MODE4|$81, (a0)    ; Mode register #4&lt;br /&gt;
    &lt;br /&gt;
    move.w  #VDPREG_PLANEA|$30, (a0)   ; Plane A address&lt;br /&gt;
    move.w  #VDPREG_PLANEB|$07, (a0)   ; Plane B address&lt;br /&gt;
    move.w  #VDPREG_SPRITE|$78, (a0)   ; Sprite address&lt;br /&gt;
    move.w  #VDPREG_WINDOW|$34, (a0)   ; Window address&lt;br /&gt;
    move.w  #VDPREG_HSCROLL|$3D, (a0)  ; HScroll address&lt;br /&gt;
    &lt;br /&gt;
    move.w  #VDPREG_SIZE|$01, (a0)     ; Tilemap size&lt;br /&gt;
    move.w  #VDPREG_WINX|$00, (a0)     ; Window X split&lt;br /&gt;
    move.w  #VDPREG_WINY|$00, (a0)     ; Window Y split&lt;br /&gt;
    move.w  #VDPREG_INCR|$02, (a0)     ; Autoincrement&lt;br /&gt;
    move.w  #VDPREG_BGCOL|$00, (a0)    ; Background color&lt;br /&gt;
    move.w  #VDPREG_HRATE|$FF, (a0)    ; HBlank IRQ rate&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information, check out https://plutiedev.com/vdp-setup&lt;br /&gt;
&lt;br /&gt;
==== VDP Register ====&lt;br /&gt;
Here is a detailed explaination of the different VDP registers:&lt;br /&gt;
https://plutiedev.com/vdp-registers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1877</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1877"/>
				<updated>2025-12-18T23:15:48Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The SEGA MegaDrive / Genesis is a 16-bit videogame console released by SEGA in 1989.&lt;br /&gt;
&lt;br /&gt;
It features:&lt;br /&gt;
* 320x240 resolution (PAL)&lt;br /&gt;
* 4x 16 color palettes&lt;br /&gt;
* Tile based display chip with 2 scrolling tilemaps&lt;br /&gt;
* 64 Sprites (up to 4x4tiles in size each)&lt;br /&gt;
* 64K of dedicated Video Memory (VRAM)&lt;br /&gt;
* YM2612 Sound Chip&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This vector table is then followed by the ROM header at 0x100&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure located at 0x100 that specifies some metadata about the ROM, like its name, author, version number, release date, region, and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Start address 	End address 	Description 	32X SH-2 address&lt;br /&gt;
$000000 	$3FFFFF 	Cartridge ROM/RAM 	$2000000-$23FFFFF&lt;br /&gt;
$400000 	$7FFFFF 	Reserved (used by the Mega-CD and 32X)&lt;br /&gt;
$800000 	$9FFFFF 	Reserved (used by the 32X)&lt;br /&gt;
$840000 	$85FFFF 	32X frame buffer 	$4000000-$401FFFF&lt;br /&gt;
$860000 	$87FFFF 	32X frame buffer overwrite mode 	$4020000-$403FFFF&lt;br /&gt;
$880000 	$8FFFFF 	32X cartridge ROM (first 512kB bank only)&lt;br /&gt;
$900000 	$9FFFFF 	32X cartridge bankswitched ROM (any 512kB bank, controlled by 32X registers)&lt;br /&gt;
$A00000 	$A0FFFF 	Z80 memory space&lt;br /&gt;
$A10000 	$A10001 	Version register&lt;br /&gt;
$A10002 	$A10003 	Controller 1 data&lt;br /&gt;
$A10004 	$A10005 	Controller 2 data&lt;br /&gt;
$A10006 	$A10007 	Expansion port data&lt;br /&gt;
$A10008 	$A10009 	Controller 1 control&lt;br /&gt;
$A1000A 	$A1000B 	Controller 2 control&lt;br /&gt;
$A1000C 	$A1000D 	Expansion port control&lt;br /&gt;
$A1000E 	$A1000F 	Controller 1 serial transmit&lt;br /&gt;
$A10010 	$A10011 	Controller 1 serial receive&lt;br /&gt;
$A10012 	$A10013 	Controller 1 serial control&lt;br /&gt;
$A10014 	$A10015 	Controller 2 serial transmit&lt;br /&gt;
$A10016 	$A10017 	Controller 2 serial receive&lt;br /&gt;
$A10018 	$A10019 	Controller 2 serial control&lt;br /&gt;
$A1001A 	$A1001B 	Expansion port serial transmit&lt;br /&gt;
$A1001C 	$A1001D 	Expansion port serial receive&lt;br /&gt;
$A1001E 	$A1001F 	Expansion port serial control&lt;br /&gt;
$A10020 	$A10FFF 	Reserved&lt;br /&gt;
$A11000 	Memory mode register&lt;br /&gt;
$A11002 	$A110FF 	Reserved&lt;br /&gt;
$A11100 	$A11101 	Z80 bus request&lt;br /&gt;
$A11102 	$A111FF 	Reserved&lt;br /&gt;
$A11200 	$A11201 	Z80 reset&lt;br /&gt;
$A11202 	$A12FFF 	Reserved&lt;br /&gt;
$A13000 	$A130FF 	TIME registers; used to send signals to the cartridge&lt;br /&gt;
$A130EC 	$A130EF 	&amp;quot;MARS&amp;quot; when 32X is attached&lt;br /&gt;
$A130F1 	SRAM access register&lt;br /&gt;
$A130F3 	Bank register for address $80000-$FFFFF&lt;br /&gt;
$A130F5 	Bank register for address $100000-$17FFFF&lt;br /&gt;
$A130F7 	Bank register for address $180000-$1FFFFF&lt;br /&gt;
$A130F9 	Bank register for address $200000-$27FFFF&lt;br /&gt;
$A130FB 	Bank register for address $280000-$2FFFFF&lt;br /&gt;
$A130FD 	Bank register for address $300000-$37FFFF&lt;br /&gt;
$A130FF 	Bank register for address $380000-$3FFFFF&lt;br /&gt;
$A14000 	$A14003 	TMSS &amp;quot;SEGA&amp;quot;&lt;br /&gt;
$A14101 	TMSS/cartridge register&lt;br /&gt;
$A14102 	$BFFFFF 	Reserved&lt;br /&gt;
$C00000 	$C00001 	VDP data port&lt;br /&gt;
$C00002 	$C00003 	VDP data port (mirror)&lt;br /&gt;
$C00004 	$C00005 	VDP control port&lt;br /&gt;
$C00006 	$C00007 	VDP control port (mirror)&lt;br /&gt;
$C00008 	$C00009 	VDP H/V counter&lt;br /&gt;
$C0000A 	$C0000F 	VDP H/V counter (mirror)&lt;br /&gt;
$C00011 	PSG output&lt;br /&gt;
$C00013 	$C00017 	PSG output (mirror)&lt;br /&gt;
$C0001C 	$C0001D 	Debug register&lt;br /&gt;
$C0001E 	$C0001F 	Debug register (mirror)&lt;br /&gt;
$C00020 	$FEFFFF 	Reserved&lt;br /&gt;
$FF0000 	$FFFFFF 	68000 RAM &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Startup ===&lt;br /&gt;
From here it jumps to the CPU entry point and we need to the minimum startup here:&lt;br /&gt;
The MegaDrive in Supervisor mode already.&lt;br /&gt;
&lt;br /&gt;
The TMSS ROM does is place the SEGA text on screen and run a timer, then I think it just unmaps itself from the address space and does a soft reset. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #'SEGA', ($A14000) ; disable TMSS so that accessing the VDP won't lock up the console&lt;br /&gt;
tst.w ($C00004)    ; test VDP CONTROL to stop the VDP, this makes it discard anything that was previously in the FIFO&lt;br /&gt;
move.w #$2700, sr ; set IPL level 7&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This setup should give you fully predictable state on every power cycle or reset&lt;br /&gt;
that's just to play it safe, but getting a spurious interrupt before you even have the chance to disable interrupt processing is pretty much impossible in the real world&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, check out https://plutiedev.com/vdp-setup&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1876</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1876"/>
				<updated>2025-12-18T22:51:08Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The SEGA MegaDrive / Genesis is a 16-bit videogame console released by SEGA in 1989.&lt;br /&gt;
&lt;br /&gt;
It features:&lt;br /&gt;
* 320x240 resolution (PAL)&lt;br /&gt;
* 4x 16 color palettes&lt;br /&gt;
* Tile based display chip with 2 scrolling tilemaps&lt;br /&gt;
* 64 Sprites (up to 4x4tiles in size each)&lt;br /&gt;
* 64K of dedicated Video Memory (VRAM)&lt;br /&gt;
* YM2612 Sound Chip&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This vector table is then followed by the ROM header at 0x100&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure located at 0x100 that specifies some metadata about the ROM, like its name, author, version number, release date, region, and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Start address 	End address 	Description 	32X SH-2 address&lt;br /&gt;
$000000 	$3FFFFF 	Cartridge ROM/RAM 	$2000000-$23FFFFF&lt;br /&gt;
$400000 	$7FFFFF 	Reserved (used by the Mega-CD and 32X)&lt;br /&gt;
$800000 	$9FFFFF 	Reserved (used by the 32X)&lt;br /&gt;
$840000 	$85FFFF 	32X frame buffer 	$4000000-$401FFFF&lt;br /&gt;
$860000 	$87FFFF 	32X frame buffer overwrite mode 	$4020000-$403FFFF&lt;br /&gt;
$880000 	$8FFFFF 	32X cartridge ROM (first 512kB bank only)&lt;br /&gt;
$900000 	$9FFFFF 	32X cartridge bankswitched ROM (any 512kB bank, controlled by 32X registers)&lt;br /&gt;
$A00000 	$A0FFFF 	Z80 memory space&lt;br /&gt;
$A10000 	$A10001 	Version register&lt;br /&gt;
$A10002 	$A10003 	Controller 1 data&lt;br /&gt;
$A10004 	$A10005 	Controller 2 data&lt;br /&gt;
$A10006 	$A10007 	Expansion port data&lt;br /&gt;
$A10008 	$A10009 	Controller 1 control&lt;br /&gt;
$A1000A 	$A1000B 	Controller 2 control&lt;br /&gt;
$A1000C 	$A1000D 	Expansion port control&lt;br /&gt;
$A1000E 	$A1000F 	Controller 1 serial transmit&lt;br /&gt;
$A10010 	$A10011 	Controller 1 serial receive&lt;br /&gt;
$A10012 	$A10013 	Controller 1 serial control&lt;br /&gt;
$A10014 	$A10015 	Controller 2 serial transmit&lt;br /&gt;
$A10016 	$A10017 	Controller 2 serial receive&lt;br /&gt;
$A10018 	$A10019 	Controller 2 serial control&lt;br /&gt;
$A1001A 	$A1001B 	Expansion port serial transmit&lt;br /&gt;
$A1001C 	$A1001D 	Expansion port serial receive&lt;br /&gt;
$A1001E 	$A1001F 	Expansion port serial control&lt;br /&gt;
$A10020 	$A10FFF 	Reserved&lt;br /&gt;
$A11000 	Memory mode register&lt;br /&gt;
$A11002 	$A110FF 	Reserved&lt;br /&gt;
$A11100 	$A11101 	Z80 bus request&lt;br /&gt;
$A11102 	$A111FF 	Reserved&lt;br /&gt;
$A11200 	$A11201 	Z80 reset&lt;br /&gt;
$A11202 	$A12FFF 	Reserved&lt;br /&gt;
$A13000 	$A130FF 	TIME registers; used to send signals to the cartridge&lt;br /&gt;
$A130EC 	$A130EF 	&amp;quot;MARS&amp;quot; when 32X is attached&lt;br /&gt;
$A130F1 	SRAM access register&lt;br /&gt;
$A130F3 	Bank register for address $80000-$FFFFF&lt;br /&gt;
$A130F5 	Bank register for address $100000-$17FFFF&lt;br /&gt;
$A130F7 	Bank register for address $180000-$1FFFFF&lt;br /&gt;
$A130F9 	Bank register for address $200000-$27FFFF&lt;br /&gt;
$A130FB 	Bank register for address $280000-$2FFFFF&lt;br /&gt;
$A130FD 	Bank register for address $300000-$37FFFF&lt;br /&gt;
$A130FF 	Bank register for address $380000-$3FFFFF&lt;br /&gt;
$A14000 	$A14003 	TMSS &amp;quot;SEGA&amp;quot;&lt;br /&gt;
$A14101 	TMSS/cartridge register&lt;br /&gt;
$A14102 	$BFFFFF 	Reserved&lt;br /&gt;
$C00000 	$C00001 	VDP data port&lt;br /&gt;
$C00002 	$C00003 	VDP data port (mirror)&lt;br /&gt;
$C00004 	$C00005 	VDP control port&lt;br /&gt;
$C00006 	$C00007 	VDP control port (mirror)&lt;br /&gt;
$C00008 	$C00009 	VDP H/V counter&lt;br /&gt;
$C0000A 	$C0000F 	VDP H/V counter (mirror)&lt;br /&gt;
$C00011 	PSG output&lt;br /&gt;
$C00013 	$C00017 	PSG output (mirror)&lt;br /&gt;
$C0001C 	$C0001D 	Debug register&lt;br /&gt;
$C0001E 	$C0001F 	Debug register (mirror)&lt;br /&gt;
$C00020 	$FEFFFF 	Reserved&lt;br /&gt;
$FF0000 	$FFFFFF 	68000 RAM &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, check out https://plutiedev.com/vdp-setup&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1875</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1875"/>
				<updated>2025-12-18T22:46:19Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The SEGA MegaDrive / Genesis is a 16-bit videogame console released by SEGA in 1989.&lt;br /&gt;
&lt;br /&gt;
It features:&lt;br /&gt;
- 320x240 resolution (PAL)&lt;br /&gt;
- 4x 16 color palettes&lt;br /&gt;
- Tile based display chip with 2 scrolling tilemaps&lt;br /&gt;
- 64 Sprites (up to 4x4tiles in size each)&lt;br /&gt;
- 64K of dedicated Video Memory (VRAM)&lt;br /&gt;
- YM2612 Sound Chip&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This vector table is then followed by the ROM header at 0x100&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure located at 0x100 that specifies some metadata about the ROM, like its name, author, version number, release date, region, and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Start address 	End address 	Description 	32X SH-2 address&lt;br /&gt;
$000000 	$3FFFFF 	Cartridge ROM/RAM 	$2000000-$23FFFFF&lt;br /&gt;
$400000 	$7FFFFF 	Reserved (used by the Mega-CD and 32X)&lt;br /&gt;
$800000 	$9FFFFF 	Reserved (used by the 32X)&lt;br /&gt;
$840000 	$85FFFF 	32X frame buffer 	$4000000-$401FFFF&lt;br /&gt;
$860000 	$87FFFF 	32X frame buffer overwrite mode 	$4020000-$403FFFF&lt;br /&gt;
$880000 	$8FFFFF 	32X cartridge ROM (first 512kB bank only)&lt;br /&gt;
$900000 	$9FFFFF 	32X cartridge bankswitched ROM (any 512kB bank, controlled by 32X registers)&lt;br /&gt;
$A00000 	$A0FFFF 	Z80 memory space&lt;br /&gt;
$A10000 	$A10001 	Version register&lt;br /&gt;
$A10002 	$A10003 	Controller 1 data&lt;br /&gt;
$A10004 	$A10005 	Controller 2 data&lt;br /&gt;
$A10006 	$A10007 	Expansion port data&lt;br /&gt;
$A10008 	$A10009 	Controller 1 control&lt;br /&gt;
$A1000A 	$A1000B 	Controller 2 control&lt;br /&gt;
$A1000C 	$A1000D 	Expansion port control&lt;br /&gt;
$A1000E 	$A1000F 	Controller 1 serial transmit&lt;br /&gt;
$A10010 	$A10011 	Controller 1 serial receive&lt;br /&gt;
$A10012 	$A10013 	Controller 1 serial control&lt;br /&gt;
$A10014 	$A10015 	Controller 2 serial transmit&lt;br /&gt;
$A10016 	$A10017 	Controller 2 serial receive&lt;br /&gt;
$A10018 	$A10019 	Controller 2 serial control&lt;br /&gt;
$A1001A 	$A1001B 	Expansion port serial transmit&lt;br /&gt;
$A1001C 	$A1001D 	Expansion port serial receive&lt;br /&gt;
$A1001E 	$A1001F 	Expansion port serial control&lt;br /&gt;
$A10020 	$A10FFF 	Reserved&lt;br /&gt;
$A11000 	Memory mode register&lt;br /&gt;
$A11002 	$A110FF 	Reserved&lt;br /&gt;
$A11100 	$A11101 	Z80 bus request&lt;br /&gt;
$A11102 	$A111FF 	Reserved&lt;br /&gt;
$A11200 	$A11201 	Z80 reset&lt;br /&gt;
$A11202 	$A12FFF 	Reserved&lt;br /&gt;
$A13000 	$A130FF 	TIME registers; used to send signals to the cartridge&lt;br /&gt;
$A130EC 	$A130EF 	&amp;quot;MARS&amp;quot; when 32X is attached&lt;br /&gt;
$A130F1 	SRAM access register&lt;br /&gt;
$A130F3 	Bank register for address $80000-$FFFFF&lt;br /&gt;
$A130F5 	Bank register for address $100000-$17FFFF&lt;br /&gt;
$A130F7 	Bank register for address $180000-$1FFFFF&lt;br /&gt;
$A130F9 	Bank register for address $200000-$27FFFF&lt;br /&gt;
$A130FB 	Bank register for address $280000-$2FFFFF&lt;br /&gt;
$A130FD 	Bank register for address $300000-$37FFFF&lt;br /&gt;
$A130FF 	Bank register for address $380000-$3FFFFF&lt;br /&gt;
$A14000 	$A14003 	TMSS &amp;quot;SEGA&amp;quot;&lt;br /&gt;
$A14101 	TMSS/cartridge register&lt;br /&gt;
$A14102 	$BFFFFF 	Reserved&lt;br /&gt;
$C00000 	$C00001 	VDP data port&lt;br /&gt;
$C00002 	$C00003 	VDP data port (mirror)&lt;br /&gt;
$C00004 	$C00005 	VDP control port&lt;br /&gt;
$C00006 	$C00007 	VDP control port (mirror)&lt;br /&gt;
$C00008 	$C00009 	VDP H/V counter&lt;br /&gt;
$C0000A 	$C0000F 	VDP H/V counter (mirror)&lt;br /&gt;
$C00011 	PSG output&lt;br /&gt;
$C00013 	$C00017 	PSG output (mirror)&lt;br /&gt;
$C0001C 	$C0001D 	Debug register&lt;br /&gt;
$C0001E 	$C0001F 	Debug register (mirror)&lt;br /&gt;
$C00020 	$FEFFFF 	Reserved&lt;br /&gt;
$FF0000 	$FFFFFF 	68000 RAM &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, check out https://plutiedev.com/vdp-setup&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1874</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1874"/>
				<updated>2025-12-18T22:44:46Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The SEGA MegaDrive / Genesis is a 16-bit videogame console released by SEGA in 1989.&lt;br /&gt;
&lt;br /&gt;
It features:&lt;br /&gt;
- 320x240 resolution (PAL)&lt;br /&gt;
- 4x 16 color palettes&lt;br /&gt;
- Tile based display chip with 2 scrolling tilemaps&lt;br /&gt;
- 64 Sprites (up to 4x4tiles in size each)&lt;br /&gt;
- 64K of dedicated Video Memory (VRAM)&lt;br /&gt;
- YM2612 Sound Chip&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This vector table is then followed by the ROM header at 0x100&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure located at 0x100 that specifies some metadata about the ROM, like its name, author, version number, release date, region, and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, check out https://plutiedev.com/vdp-setup&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1873</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1873"/>
				<updated>2025-12-18T22:42:25Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The SEGA MegaDrive / Genesis is a 16-bit videogame console released by SEGA in 1989.&lt;br /&gt;
&lt;br /&gt;
It features:&lt;br /&gt;
- 320x240 resolution (PAL)&lt;br /&gt;
- 4x 16 color palettes&lt;br /&gt;
- Tile based display chip with 2 scrolling tilemaps&lt;br /&gt;
- 64 Sprites (up to 4x4tiles in size each)&lt;br /&gt;
- 64K of dedicated Video Memory (VRAM)&lt;br /&gt;
- YM2612 Sound Chip&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This vector table is then followed by the ROM header at 0x100&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure located at 0x100 that specifies some metadata about the ROM, like its name, author, version number, release date, region, and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1872</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1872"/>
				<updated>2025-12-18T22:27:01Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
The ROM Header is a structure that specifies some metadata about the ROM, like its name, author, version number, release date, region,&lt;br /&gt;
and any special peripherals used.&lt;br /&gt;
&lt;br /&gt;
Note that the Mega Drive console itself doesn't read any of this, it's more a convenience for the programmer, but most emulators will read the title and region. Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1871</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1871"/>
				<updated>2025-12-18T22:20:18Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): MDTools ( https://github.com/sikthehedgehog/mdtools )&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== CPU Vector table ===&lt;br /&gt;
This must be the very first thing in the ROM, since the CPU reads it from 0x0000 on bootup.&lt;br /&gt;
The Vector table is a table of addresses that the CPU needs to know about - things like stack address, &amp;quot;main()&amp;quot; function address,&lt;br /&gt;
vertical/horizontal interrupt addresses, etc.&lt;br /&gt;
For any interrupts we don't want to handle, we specify INT_Null (an interrupt at the bottom of the file that doesn't do anything).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
        dc.l   0x00FFE000			; Initial stack pointer value&lt;br /&gt;
	dc.l   CPU_EntryPoint		; Start of program&lt;br /&gt;
	dc.l   CPU_Exception 		; Bus error&lt;br /&gt;
	dc.l   CPU_Exception 		; Address error&lt;br /&gt;
	dc.l   CPU_Exception 		; Illegal instruction&lt;br /&gt;
	dc.l   CPU_Exception 		; Division by zero&lt;br /&gt;
	dc.l   CPU_Exception 		; CHK CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; TRAPV CPU_Exception&lt;br /&gt;
	dc.l   CPU_Exception 		; Privilege violation&lt;br /&gt;
	dc.l   INT_Null				; TRACE exception&lt;br /&gt;
	dc.l   INT_Null				; Line-A emulator&lt;br /&gt;
	dc.l   INT_Null				; Line-F emulator&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Spurious exception&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 1&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 2&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 3&lt;br /&gt;
	dc.l   INT_HInterrupt		; IRQ level 4 (horizontal retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null  			; IRQ level 5&lt;br /&gt;
	dc.l   INT_VInterrupt		; IRQ level 6 (vertical retrace interrupt)&lt;br /&gt;
	dc.l   INT_Null				; IRQ level 7&lt;br /&gt;
	dc.l   INT_Null				; TRAP #00 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #01 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #02 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #03 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #04 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #05 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #06 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #07 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #08 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #09 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #10 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #11 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #12 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #13 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #14 exception&lt;br /&gt;
	dc.l   INT_Null				; TRAP #15 exception&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
	dc.l   INT_Null				; Unused (reserved)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ROM Header ===&lt;br /&gt;
Further header information at: https://plutiedev.com/rom-header&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1870</id>
		<title>Sega MegaDrive</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sega_MegaDrive&amp;diff=1870"/>
				<updated>2025-12-18T22:12:49Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: Created page with &amp;quot;== SEGA MegaDrive / Genesis == The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== SEGA MegaDrive / Genesis ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): BlastEm ( https://www.retrodev.com/blastem/ )&lt;br /&gt;
* Tool(s): Various ROM Tools&lt;br /&gt;
* Hardware: Sega MegaDrive / Genesis console with a way to access ROM files.&lt;br /&gt;
&lt;br /&gt;
The real hardware and BlastEm emulator don't require exact ROM headers, but you might want to distribute an emulator friendly version of your production as well for broader emulator compatibility.&lt;br /&gt;
&lt;br /&gt;
=== Header ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
==== VDP ====&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Sprites ====&lt;br /&gt;
To be added&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
To be added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; to be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=22 SEGA MegaDrive demoscene productions]&lt;br /&gt;
* [https://plutiedev.com/ SEGA MegaDrive Programming]&lt;br /&gt;
* [https://plutiedev.com/mirror/kabuto-hardware-notes SEGA MegaDrive Hardware notes]&lt;br /&gt;
* [https://www.scribd.com/document/637611089/SEGA-Mega-Drive-Assembly-Workshop SEGA MegaDrive Assembly Workshop]&lt;br /&gt;
* [https://github.com/BigEvilCorporation/megadrive_samples/tree/master Various SEGA MegaDrive assembler examples]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=1869</id>
		<title>Motorola 68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Motorola_68000&amp;diff=1869"/>
				<updated>2025-12-18T22:03:49Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Wanting to start sizecoding on a Motorola 68000 platforms in this day and age can be tough. &lt;br /&gt;
So lets start with a list of well known Motorola 68000 systems you could target for sizecoding.&lt;br /&gt;
&lt;br /&gt;
== Motorola 68000 Platforms ==&lt;br /&gt;
Here is a list of well known Motorola 68000 platforms you could target for sizecoding:&lt;br /&gt;
*'''[[Atari ST]]''' - Atari ST Sizecoding information&lt;br /&gt;
*'''[[Commodore Amiga]]''' - Commodore Amiga Sizecoding information&lt;br /&gt;
*'''[[Atari Jaguar]]''' - Atari Jaguar Sizecoding information&lt;br /&gt;
*'''[[Sega MegaDrive]]''' - SEGA MegaDrive / Genesis information&lt;br /&gt;
*'''[[Spectrum QL]]''' - Spectrum QL information&lt;br /&gt;
*'''[[X68000]]''' - Sharp X68000 information&lt;br /&gt;
&lt;br /&gt;
== The Motorola 68000 processor ==&lt;br /&gt;
The Motorola 68000/68k processor is a 16-bit Big-Endian format processor, using 32-bit register and addresses.&lt;br /&gt;
&lt;br /&gt;
This means that instruction sizes on average are either 2 or 4 bytes each, and 6 bytes for longword / 32-bit instructions.&lt;br /&gt;
&lt;br /&gt;
Note: The assigment direction is source,dest instead of dest,source !!!&lt;br /&gt;
&lt;br /&gt;
==== Registers ====&lt;br /&gt;
&lt;br /&gt;
* D0..D7 - 8 x 32 bit General Purpose Registers&lt;br /&gt;
&lt;br /&gt;
* A0..A6 - 7 x 32 bit Address Registers&lt;br /&gt;
&lt;br /&gt;
* A7 - 32-bit Stack-Address Register&lt;br /&gt;
&lt;br /&gt;
==== Instructions timing ====&lt;br /&gt;
The number of cycles for each instruction is different depending of processor model in M68K family.&lt;br /&gt;
: http://oldwww.nvg.ntnu.no/amiga/MC680x0_Sections/mc68000timing.HTML&lt;br /&gt;
&lt;br /&gt;
== Size considerations ==&lt;br /&gt;
Here are some general rule of thumbs when it comes to size consideration when programming the M68000&lt;br /&gt;
&lt;br /&gt;
* Moving/Calculating Register from/to registers - 2 bytes&lt;br /&gt;
* Moving/Calculating with byte or word values - 4 bytes&lt;br /&gt;
* Moving/Calculating with long values - 6 bytes&lt;br /&gt;
&lt;br /&gt;
Shorter variants:&lt;br /&gt;
* moveq #value, reg : 2 bytes - Moves a values -128...127 to a register&lt;br /&gt;
* addq #value, reg : 2 bytes - Adds a values 0..8 to a register&lt;br /&gt;
* subq #value, reg : 2 bytes - Subtracts a values 0..8 from a register&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Generic 68K sinus table generator ==&lt;br /&gt;
Here is a fairly generic 68k sinus table generator (14 bytes on Atari ST/Amiga) as well as a 10-byte zigzag generator.&lt;br /&gt;
* [https://demozoo.org/productions/310191/ Singen68k]&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
* [http://www.beycan.net/eklenen/M68000_Instruction_Set.pdf M68000 Instruction Set]&lt;br /&gt;
* [http://www.easy68k.com/ EASy68K Editor/Assembler/Simulator for the 68000]&lt;br /&gt;
* [http://www.easy68k.com/paulrsm/index.html Various Motorola 68k resources]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ZX_Spectrum&amp;diff=1868</id>
		<title>ZX Spectrum</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ZX_Spectrum&amp;diff=1868"/>
				<updated>2025-12-15T12:09:07Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ZX Spectrum  ==&lt;br /&gt;
The ZX Spectrum consists of a Z80A @ 3.5 MHz CPU with either 16k, 48k or 128K of RAM. Most demos are targeted at the Spectrum 128 because it includes more memory, a shadow screen buffer and an AY soundchip. The different models have slightly different timings - this will cause issues if you are doing cycle-exact effects like multi-color.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
Setting up your development platform for the ZX Spectrum is quite easy, first get the following tools:&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/z00m128/sjasmplus/releases/latest SjASMPlus (z00m's fork)] - cross-platform open source assembler with nice macros for creating Binaries, TAP, TRD and SNA snapshot files out of the box, embedded Lua scripting and support for similar CPUs (Z80/R800/Z80N/i8080/LR35902).&lt;br /&gt;
* [https://github.com/EdouardBERGE/rasm/releases/latest Rasm] - extremely fast cross-platform Z80 assembler with many features&lt;br /&gt;
* Pasmo - for the .TAP create. Available at : http://pasmo.speccy.org&lt;br /&gt;
* Emulator(s): I Found [https://www.zophar.net/sinclair/zx-spin.html ZX Sping], [https://sourceforge.net/projects/fuse-emulator/ FUSE], [https://sourceforge.net/projects/unrealspeccyp/ UnrealSpeccy] and [https://www.aptanet.org/eightyone/ EightyOne] to work best for my usecase. Most emulators can read TAP, SNA and TRD files out of the box.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can use the online Bazematic tool to do a lot of the early development at  [https://bazematic.demozoo.org bazematic.demozoo.org]&lt;br /&gt;
&lt;br /&gt;
=== Start values ===&lt;br /&gt;
Upon startup (when called from basic), the following values can assumed:&lt;br /&gt;
&lt;br /&gt;
* The alternate HL register is set to 0x2758&lt;br /&gt;
* IY = 0x5c3a&lt;br /&gt;
* BC = start address&lt;br /&gt;
* A = C&lt;br /&gt;
&lt;br /&gt;
=== Memory Configuration ===&lt;br /&gt;
128K separated to 8 pages (16384 bytes size)&lt;br /&gt;
Default configuration is:&lt;br /&gt;
&lt;br /&gt;
: page 5: $4000-$7fff&lt;br /&gt;
: page 2: $8000-$Bfff&lt;br /&gt;
: page 0: $C000-$Ffff&lt;br /&gt;
&lt;br /&gt;
There are two screens - page 7 and page 5.&lt;br /&gt;
port $7FFD allow to control memory and screens:&lt;br /&gt;
: bits 0-2 - page number mapped to memory at $C0000&lt;br /&gt;
: bit 3 - Select page 5(0) or page 7(1) to be displayed.&lt;br /&gt;
: bit 4 - ROM Select. 0-128K,1-48K&lt;br /&gt;
&lt;br /&gt;
Example of use&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
loop: ei&lt;br /&gt;
 halt&lt;br /&gt;
pg: ld a,$17&lt;br /&gt;
 ld bc,$7ffd&lt;br /&gt;
 out (c),a&lt;br /&gt;
 xor $0A&lt;br /&gt;
 ld (pg+1),a&lt;br /&gt;
... do something with $C000-$DB00&lt;br /&gt;
 jp loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$17 is use 48K, map page 7&lt;br /&gt;
After xor $0A we'll get value $1D(use 48K ROM, display screen at page 7 and map page5 at $C000).This is so-called &amp;quot;double buffering&amp;quot;.&lt;br /&gt;
See also : https://worldofspectrum.org/faq/reference/128kreference.htm&lt;br /&gt;
&lt;br /&gt;
=== Graphics ===&lt;br /&gt;
Video display on the ZX Spectrum is mostly CPU based with little hardware features. No hardware sprites, no specific text or video modes, only a 256x192 byte screenbuffer with 1bit pixeldata located at $4000 in memory. &lt;br /&gt;
It is ordened a bit strange in 3 sections of 256x64 pixels, then character rows then subrows.&lt;br /&gt;
&lt;br /&gt;
Address = 010RRLLL RRRCCCCC &lt;br /&gt;
&lt;br /&gt;
* where RRRRR is the row number (0..23)&lt;br /&gt;
* CCCCC is the column number (0..31)&lt;br /&gt;
* LLL is the line number within the cell (0..7)&lt;br /&gt;
&lt;br /&gt;
Calculating a screen address from XY coordinates is complicated due to the weird screen layout. In a larger demo you would generate a lookup table - it's usually best to avoid such calculations in small demos, but it can be done in under 30 bytes, eg: http://www.breakintoprogram.co.uk/computers/zx-spectrum/screen-memory-layout&lt;br /&gt;
&lt;br /&gt;
==== Border Color ====&lt;br /&gt;
You can set the border color to any of the 8 colors with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld a,0 ; bottom three bits of a contain the color&lt;br /&gt;
out (254),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Color RAM ====&lt;br /&gt;
The ZX Spectrum has a 32x24 colormap located at $5800 where you can write color information for each 8x8 tile. &lt;br /&gt;
It has has 8 colors (INK and PAPER) with 2 brightness settings that can be set like this.&lt;br /&gt;
&lt;br /&gt;
color = brightness(64) | (PAPER&amp;lt;&amp;lt;3) | INK&lt;br /&gt;
&lt;br /&gt;
Because updating pixel memory can be slow, especially when you are grasping for bytes, some of the tiny intros on the zx spectrum prefer to use the colorram for the effect, sometimes in combination with an overlaying pattern.&lt;br /&gt;
&lt;br /&gt;
==== Example of using Color RAM ====&lt;br /&gt;
Now to get something on screen, lets fill our colorram with a simple AND pattern, like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
 ld de,5800h&lt;br /&gt;
 ld b,24&lt;br /&gt;
yloop:&lt;br /&gt;
   ld c,32&lt;br /&gt;
xloop:&lt;br /&gt;
   ld a,c&lt;br /&gt;
   and b&lt;br /&gt;
   and 7    ; make sure range is 0..7&lt;br /&gt;
   ld (de),a&lt;br /&gt;
   inc de&lt;br /&gt;
   dec c&lt;br /&gt;
   jr nz,xloop&lt;br /&gt;
djnz yloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using a Backbuffer ====&lt;br /&gt;
While the above code will run fine, you might want to consider using a backbuffer for more complex stuff. You can then simply write to another adress define by BACKBUFFER (for example A000) and copy the buffer to colorram like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
halt               ; synchronize &lt;br /&gt;
ld hl,BACKBUFFER   &lt;br /&gt;
ld de,5800h&lt;br /&gt;
ld bc,768&lt;br /&gt;
ldir&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another alternative method is to use the 128's memory paging, which provides a second screen buffer. This buffer is located at a different memeory location, but otherwise it is the same:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
	; main loop starts here&lt;br /&gt;
	ld	a,00010111b	; set up memory banks and screen here&lt;br /&gt;
mainloop&lt;br /&gt;
	halt			; sync&lt;br /&gt;
	xor	00001010b	; flip screens&lt;br /&gt;
	out	($fd),a&lt;br /&gt;
	push	af&lt;br /&gt;
&lt;br /&gt;
	; render code goes here&lt;br /&gt;
	; screen buffer is location at 0xC000 instead of 0x4000&lt;br /&gt;
&lt;br /&gt;
	pop	af&lt;br /&gt;
	jr	mainloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Overlaying simple character/pixel graphics ====&lt;br /&gt;
If you don't want to use a solid color/tile for. &lt;br /&gt;
You could copy a single tile across the screen at startup for some flair.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
   ld a,0x55   ; 01010101 pattern&lt;br /&gt;
   ld bc,0x1800&lt;br /&gt;
copyloop:&lt;br /&gt;
   ld (de),a&lt;br /&gt;
   inc de&lt;br /&gt;
   dec c&lt;br /&gt;
jr nz,copyloop&lt;br /&gt;
djnz copyloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could generate a pattern using predefined data, logic operations or random noise/data.&lt;br /&gt;
&lt;br /&gt;
==== General pixel plot routine ====&lt;br /&gt;
Here is a generalised pixel-plot routine provided by Baze:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld   h,TAB&lt;br /&gt;
ld   l,b     ; L = Y&lt;br /&gt;
ld   d,(hl)  ; pick 0 1 0 y7 y6 y2 y1 y0&lt;br /&gt;
inc  h&lt;br /&gt;
ld   h,(hl)  ; depending on y5 y4 y3, pick one of eight sub-tables&lt;br /&gt;
ld   l,c     ; L = X&lt;br /&gt;
ld   e,(hl)  ; pick y5 y4 y3 x7 x6 x5 x4 x3&lt;br /&gt;
inc  h&lt;br /&gt;
ld   a,(de)&lt;br /&gt;
or   (hl)    ; pixel mask 0b1000000 &amp;gt;&amp;gt; (X &amp;amp; 7)&lt;br /&gt;
ld   (de),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ROM Routines ===&lt;br /&gt;
Alternatively you can use the built-in, but very slow, ROM routines to plot pixels and some other primitives:&lt;br /&gt;
&lt;br /&gt;
==== Calculate Pixel coordinate: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;IN: A=X coordinate,C=L=Y coordinate&lt;br /&gt;
;OUT: HL=screen address,A=bit value&lt;br /&gt;
call #22B0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plot Pixel: ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;write pixel&lt;br /&gt;
 CALL  8933 ; C=X(0..255),B=Y(0..175),5C7D=COORDS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: This routine will only work if you supply it values withing the provided limits above!&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The original Spectrum has only a 1 bit sound capability (BEEP) through its internal speaker.&lt;br /&gt;
Later models included the AY-3-8910 Soundchip which provides 3 channels of PSG sound.&lt;br /&gt;
&lt;br /&gt;
==== Make some noise - Beeper ====&lt;br /&gt;
Setting/toggling bit 4 of port 254 will enable the beeper speaker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
		ld a,$10	;Bit 4 set&lt;br /&gt;
beeploop:	xor $10		;toggle Bit 4&lt;br /&gt;
		out (254),a&lt;br /&gt;
		ld b,90		;wait&lt;br /&gt;
		djnz $&lt;br /&gt;
		jp beeploop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the bottom three bits of port 254 also set the border color (see above).&lt;br /&gt;
&lt;br /&gt;
==== AY Sound: Make some noise ====&lt;br /&gt;
You can access the AY soundchip by outputting to the following ports:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld bc,0xfffd&lt;br /&gt;
ld a, ay register number&lt;br /&gt;
out (c),a&lt;br /&gt;
ld b,0xbf	&lt;br /&gt;
ld a, data byte&lt;br /&gt;
out (c),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information about the soundchip, check out:&lt;br /&gt;
https://www.atarimagazines.com/v4n7/stsound.html&lt;br /&gt;
&lt;br /&gt;
=== Other Useful routines ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;calculate address of next line,HL=address&lt;br /&gt;
down_hl:&lt;br /&gt;
 INC h&lt;br /&gt;
 LD A,h&lt;br /&gt;
 AND 7&lt;br /&gt;
 RET NZ&lt;br /&gt;
 LD A,L&lt;br /&gt;
 ADD A,#20&lt;br /&gt;
 LD L,A&lt;br /&gt;
 RET C&lt;br /&gt;
 LD A,H&lt;br /&gt;
 SUB 8&lt;br /&gt;
 LD H,A&lt;br /&gt;
 RET&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;move up at screen, HL=address&lt;br /&gt;
up_hl&lt;br /&gt;
     LD A,H&lt;br /&gt;
     DEC H&lt;br /&gt;
     AND 7&lt;br /&gt;
     ret nz&lt;br /&gt;
     LD A,L&lt;br /&gt;
     SUB 32&lt;br /&gt;
     LD L,A&lt;br /&gt;
     ret c&lt;br /&gt;
     LD A,H&lt;br /&gt;
     ADD A,8&lt;br /&gt;
     LD H,A&lt;br /&gt;
 ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;Calculate vertical line screen Address, IN : A=Y coordinate, OUT : HL=address&lt;br /&gt;
py2saddr:&lt;br /&gt;
        ld l,a&lt;br /&gt;
;	ld a,l&lt;br /&gt;
	and $07&lt;br /&gt;
	ld h,a&lt;br /&gt;
	ld a,l&lt;br /&gt;
	and $c0&lt;br /&gt;
	rra&lt;br /&gt;
	inc a&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	or h&lt;br /&gt;
	ld h,a&lt;br /&gt;
	ld a,l&lt;br /&gt;
	add a&lt;br /&gt;
	add a&lt;br /&gt;
	and $e0&lt;br /&gt;
	ld l,a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;Calculate Attribute address, IB: reg D=Y,reg E=X, OUT: HL=address, destroys DE&lt;br /&gt;
 ld l,d&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 ld h,$11&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 ld d,0&lt;br /&gt;
 add hl,de&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or alter version&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;H=Y coordinate,L=X coordinate&lt;br /&gt;
	ld a,h&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	push af&lt;br /&gt;
	and 3&lt;br /&gt;
	add a,$58&lt;br /&gt;
	ld h,a&lt;br /&gt;
	pop af&lt;br /&gt;
	and %11100000&lt;br /&gt;
	add a,l&lt;br /&gt;
	ld l,a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
I found resources on ZX Spectrum sizecoding to be sparse.&lt;br /&gt;
* All kinds of Z80 Information http://www.z80.info/index.htm&lt;br /&gt;
* Another source for good Z80 Information http://z80-heaven.wikidot.com&lt;br /&gt;
* Assembler subforum on world of spectrum https://worldofspectrum.org/forums/categories/assembler&lt;br /&gt;
* Development subforum on Spectrum Computing https://spectrumcomputing.co.uk/forums/viewforum.php?f=6&lt;br /&gt;
* Blogpost on ZX Spectrum coding from a X86 coder's perspective on superogue's sizecdoing blog http://marquee.revival-studios.com/blog/blog_fluxus.html&lt;br /&gt;
* Easy to read list of all Z80 instructions (including undocumented ones) with size and timing information https://clrhome.org/table/&lt;br /&gt;
* Detailed information on the screen layout http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout/ http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout-part-two/ and http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout-part-three/&lt;br /&gt;
&lt;br /&gt;
=== Small demos with documented source code ===&lt;br /&gt;
* Ceci N'est Pas Un Cube by Ate Bit https://www.pouet.net/prod.php?which=29691&lt;br /&gt;
* Zxwister by Ate Bit https://www.pouet.net/prod.php?which=44123&lt;br /&gt;
* Muse by Ate Bit https://www.pouet.net/prod.php?which=62880&lt;br /&gt;
* Starlet Guitarlet by HOOY-PROGRAM https://www.pouet.net/prod.php?which=52553&lt;br /&gt;
* Clangers On The Dancefloor by HOOY-PROGRAM https://www.pouet.net/prod.php?which=29696&lt;br /&gt;
* Chessington World Of Adventure by HOOY-PROGRAM https://www.pouet.net/prod.php?which=76074&lt;br /&gt;
* Roll Me Gently by Joker https://www.pouet.net/prod.php?which=86338&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ZX_Spectrum&amp;diff=1867</id>
		<title>ZX Spectrum</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ZX_Spectrum&amp;diff=1867"/>
				<updated>2025-12-15T12:08:29Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ZX Spectrum  ==&lt;br /&gt;
The ZX Spectrum consists of a Z80A @ 3.5 MHz CPU with either 16k, 48k or 128K of RAM. Most demos are targeted at the Spectrum 128 because it includes more memory, a shadow screen buffer and an AY soundchip. The different models have slightly different timings - this will cause issues if you are doing cycle-exact effects like multi-color.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
Setting up your development platform for the ZX Spectrum is quite easy, first get the following tools:&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/z00m128/sjasmplus/releases/latest SjASMPlus (z00m's fork)] - cross-platform open source assembler with nice macros for creating Binaries, TAP, TRD and SNA snapshot files out of the box, embedded Lua scripting and support for similar CPUs (Z80/R800/Z80N/i8080/LR35902).&lt;br /&gt;
* [https://github.com/EdouardBERGE/rasm/releases/latest Rasm] - extremely fast cross-platform Z80 assembler with many features&lt;br /&gt;
* Pasmo - for the .TAP create. Available at : http://pasmo.speccy.org&lt;br /&gt;
* Emulator(s): I Found [https://www.zophar.net/sinclair/zx-spin.html ZX Sping], [https://sourceforge.net/projects/fuse-emulator/ FUSE], [https://sourceforge.net/projects/unrealspeccyp/ UnrealSpeccy] and [https://www.aptanet.org/eightyone/ EightyOne] to work best for my usecase. Most emulators can read TAP, SNA and TRD files out of the box.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can use the online Bazematic tool to do a lot of the early development at  [https://bazematic.demozoo.org bazematic.demozoo.org]&lt;br /&gt;
&lt;br /&gt;
=== Start values ===&lt;br /&gt;
Upon startup (when called from basic), the following values can assumed:&lt;br /&gt;
&lt;br /&gt;
* The alternate HL register is set to 0x2758&lt;br /&gt;
* IY = 0x5c3a&lt;br /&gt;
* BC = start address&lt;br /&gt;
* A = C&lt;br /&gt;
&lt;br /&gt;
=== Memory Configuration ===&lt;br /&gt;
128K separated to 8 pages (16384 bytes size)&lt;br /&gt;
Default configuration is:&lt;br /&gt;
&lt;br /&gt;
: page 5: $4000-$7fff&lt;br /&gt;
: page 2: $8000-$Bfff&lt;br /&gt;
: page 0: $C000-$Ffff&lt;br /&gt;
&lt;br /&gt;
There are two screens - page 7 and page 5.&lt;br /&gt;
port $7FFD allow to control memory and screens:&lt;br /&gt;
: bits 0-2 - page number mapped to memory at $C0000&lt;br /&gt;
: bit 3 - Select page 5(0) or page 7(1) to be displayed.&lt;br /&gt;
: bit 4 - ROM Select. 0-128K,1-48K&lt;br /&gt;
&lt;br /&gt;
Example of use&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
loop: ei&lt;br /&gt;
 halt&lt;br /&gt;
pg: ld a,$17&lt;br /&gt;
 ld bc,$7ffd&lt;br /&gt;
 out (c),a&lt;br /&gt;
 xor $0A&lt;br /&gt;
 ld (pg+1),a&lt;br /&gt;
... do something with $C000-$DB00&lt;br /&gt;
 jp loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$17 is use 48K, map page 7&lt;br /&gt;
After xor $0A we'll get value $1D(use 48K ROM, display screen at page 7 and map page5 at $C000).This is so-called &amp;quot;double buffering&amp;quot;.&lt;br /&gt;
See also : https://worldofspectrum.org/faq/reference/128kreference.htm&lt;br /&gt;
&lt;br /&gt;
=== Graphics ===&lt;br /&gt;
Video display on the ZX Spectrum is mostly CPU based with little hardware features. No hardware sprites, no specific text or video modes, only a 256x192 byte screenbuffer with 1bit pixeldata located at $4000 in memory. &lt;br /&gt;
It is ordened a bit strange in 3 sections of 256x64 pixels, then character rows then subrows.&lt;br /&gt;
&lt;br /&gt;
Address = 010RRLLL RRRCCCCC &lt;br /&gt;
&lt;br /&gt;
* where RRRRR is the row number (0..23)&lt;br /&gt;
* CCCCC is the column number (0..31)&lt;br /&gt;
* LLL is the line number within the cell (0..7)&lt;br /&gt;
&lt;br /&gt;
Calculating a screen address from XY coordinates is complicated due to the weird screen layout. In a larger demo you would generate a lookup table - it's usually best to avoid such calculations in small demos, but it can be done in under 30 bytes, eg: http://www.breakintoprogram.co.uk/computers/zx-spectrum/screen-memory-layout&lt;br /&gt;
&lt;br /&gt;
==== Border Color ====&lt;br /&gt;
You can set the border color to any of the 8 colors with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld a,0 ; bottom three bits of a contain the color&lt;br /&gt;
out (254),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Color RAM ====&lt;br /&gt;
The ZX Spectrum has a 32x24 colormap located at $5800 where you can write color information for each 8x8 tile. &lt;br /&gt;
It has has 8 colors (INK and PAPER) with 2 brightness settings that can be set like this.&lt;br /&gt;
&lt;br /&gt;
color = brightness(64) | (PAPER&amp;lt;&amp;lt;3) | INK&lt;br /&gt;
&lt;br /&gt;
Because updating pixel memory can be slow, especially when you are grasping for bytes, some of the tiny intros on the zx spectrum prefer to use the colorram for the effect, sometimes in combination with an overlaying pattern.&lt;br /&gt;
&lt;br /&gt;
==== Example of using Color RAM ====&lt;br /&gt;
Now to get something on screen, lets fill our colorram with a simple AND pattern, like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
 ld de,5800h&lt;br /&gt;
 ld b,24&lt;br /&gt;
yloop:&lt;br /&gt;
   ld c,32&lt;br /&gt;
xloop:&lt;br /&gt;
   ld a,c&lt;br /&gt;
   and b&lt;br /&gt;
   and 7    ; make sure range is 0..7&lt;br /&gt;
   ld (de),a&lt;br /&gt;
   inc de&lt;br /&gt;
   dec c&lt;br /&gt;
   jr nz,xloop&lt;br /&gt;
djnz yloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using a Backbuffer ====&lt;br /&gt;
While the above code will run fine, you might want to consider using a backbuffer for more complex stuff. You can then simply write to another adress define by BACKBUFFER (for example A000) and copy the buffer to colorram like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
halt               ; synchronize &lt;br /&gt;
ld hl,BACKBUFFER   &lt;br /&gt;
ld de,5800h&lt;br /&gt;
ld bc,768&lt;br /&gt;
ldir&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another alternative method is to use the 128's memory paging, which provides a second screen buffer. This buffer is located at a different memeory location, but otherwise it is the same:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
	; main loop starts here&lt;br /&gt;
	ld	a,00010111b	; set up memory banks and screen here&lt;br /&gt;
mainloop&lt;br /&gt;
	halt			; sync&lt;br /&gt;
	xor	00001010b	; flip screens&lt;br /&gt;
	out	($fd),a&lt;br /&gt;
	push	af&lt;br /&gt;
&lt;br /&gt;
	; render code goes here&lt;br /&gt;
	; screen buffer is location at 0xC000 instead of 0x4000&lt;br /&gt;
&lt;br /&gt;
	pop	af&lt;br /&gt;
	jr	mainloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Overlaying simple character/pixel graphics ====&lt;br /&gt;
If you don't want to use a solid color/tile for. &lt;br /&gt;
You could copy a single tile across the screen at startup for some flair.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
   ld a,0x55   ; 01010101 pattern&lt;br /&gt;
   ld bc,0x1800&lt;br /&gt;
copyloop:&lt;br /&gt;
   ld (de),a&lt;br /&gt;
   inc de&lt;br /&gt;
   dec c&lt;br /&gt;
jr nz,copyloop&lt;br /&gt;
djnz copyloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could generate a pattern using predefined data, logic operations or random noise/data.&lt;br /&gt;
&lt;br /&gt;
==== General pixel plot routine ====&lt;br /&gt;
Here is a generalised pixel-plot routine provided by Baze:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld   h,TAB&lt;br /&gt;
ld   l,b     ; L = Y&lt;br /&gt;
ld   d,(hl)  ; pick 0 1 0 y7 y6 y2 y1 y0&lt;br /&gt;
inc  h&lt;br /&gt;
ld   h,(hl)  ; depending on y5 y4 y3, pick one of eight sub-tables&lt;br /&gt;
ld   l,c     ; L = X&lt;br /&gt;
ld   e,(hl)  ; pick y5 y4 y3 x7 x6 x5 x4 x3&lt;br /&gt;
inc  h&lt;br /&gt;
ld   a,(de)&lt;br /&gt;
or   (hl)    ; pixel mask 0b1000000 &amp;gt;&amp;gt; (X &amp;amp; 7)&lt;br /&gt;
ld   (de),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ROM Routines ===&lt;br /&gt;
Alternatively you can use the built-in, but very slow, ROM routines to plot pixels and some other primitives:&lt;br /&gt;
&lt;br /&gt;
Calculate Pixel coordinate:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;IN: A=X coordinate,C=L=Y coordinate&lt;br /&gt;
;OUT: HL=screen address,A=bit value&lt;br /&gt;
call #22B0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plot Pixel:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;write pixel&lt;br /&gt;
 CALL  8933 ; C=X(0..255),B=Y(0..175),5C7D=COORDS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note: This routine will only work if you supply it values withing the provided limits above!&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The original Spectrum has only a 1 bit sound capability (BEEP) through its internal speaker.&lt;br /&gt;
Later models included the AY-3-8910 Soundchip which provides 3 channels of PSG sound.&lt;br /&gt;
&lt;br /&gt;
==== Make some noise - Beeper ====&lt;br /&gt;
Setting/toggling bit 4 of port 254 will enable the beeper speaker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
		ld a,$10	;Bit 4 set&lt;br /&gt;
beeploop:	xor $10		;toggle Bit 4&lt;br /&gt;
		out (254),a&lt;br /&gt;
		ld b,90		;wait&lt;br /&gt;
		djnz $&lt;br /&gt;
		jp beeploop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the bottom three bits of port 254 also set the border color (see above).&lt;br /&gt;
&lt;br /&gt;
==== AY Sound: Make some noise ====&lt;br /&gt;
You can access the AY soundchip by outputting to the following ports:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld bc,0xfffd&lt;br /&gt;
ld a, ay register number&lt;br /&gt;
out (c),a&lt;br /&gt;
ld b,0xbf	&lt;br /&gt;
ld a, data byte&lt;br /&gt;
out (c),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information about the soundchip, check out:&lt;br /&gt;
https://www.atarimagazines.com/v4n7/stsound.html&lt;br /&gt;
&lt;br /&gt;
=== Other Useful routines ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;calculate address of next line,HL=address&lt;br /&gt;
down_hl:&lt;br /&gt;
 INC h&lt;br /&gt;
 LD A,h&lt;br /&gt;
 AND 7&lt;br /&gt;
 RET NZ&lt;br /&gt;
 LD A,L&lt;br /&gt;
 ADD A,#20&lt;br /&gt;
 LD L,A&lt;br /&gt;
 RET C&lt;br /&gt;
 LD A,H&lt;br /&gt;
 SUB 8&lt;br /&gt;
 LD H,A&lt;br /&gt;
 RET&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;move up at screen, HL=address&lt;br /&gt;
up_hl&lt;br /&gt;
     LD A,H&lt;br /&gt;
     DEC H&lt;br /&gt;
     AND 7&lt;br /&gt;
     ret nz&lt;br /&gt;
     LD A,L&lt;br /&gt;
     SUB 32&lt;br /&gt;
     LD L,A&lt;br /&gt;
     ret c&lt;br /&gt;
     LD A,H&lt;br /&gt;
     ADD A,8&lt;br /&gt;
     LD H,A&lt;br /&gt;
 ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;Calculate vertical line screen Address, IN : A=Y coordinate, OUT : HL=address&lt;br /&gt;
py2saddr:&lt;br /&gt;
        ld l,a&lt;br /&gt;
;	ld a,l&lt;br /&gt;
	and $07&lt;br /&gt;
	ld h,a&lt;br /&gt;
	ld a,l&lt;br /&gt;
	and $c0&lt;br /&gt;
	rra&lt;br /&gt;
	inc a&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	or h&lt;br /&gt;
	ld h,a&lt;br /&gt;
	ld a,l&lt;br /&gt;
	add a&lt;br /&gt;
	add a&lt;br /&gt;
	and $e0&lt;br /&gt;
	ld l,a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;Calculate Attribute address, IB: reg D=Y,reg E=X, OUT: HL=address, destroys DE&lt;br /&gt;
 ld l,d&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 ld h,$11&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 ld d,0&lt;br /&gt;
 add hl,de&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or alter version&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;H=Y coordinate,L=X coordinate&lt;br /&gt;
	ld a,h&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	push af&lt;br /&gt;
	and 3&lt;br /&gt;
	add a,$58&lt;br /&gt;
	ld h,a&lt;br /&gt;
	pop af&lt;br /&gt;
	and %11100000&lt;br /&gt;
	add a,l&lt;br /&gt;
	ld l,a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
I found resources on ZX Spectrum sizecoding to be sparse.&lt;br /&gt;
* All kinds of Z80 Information http://www.z80.info/index.htm&lt;br /&gt;
* Another source for good Z80 Information http://z80-heaven.wikidot.com&lt;br /&gt;
* Assembler subforum on world of spectrum https://worldofspectrum.org/forums/categories/assembler&lt;br /&gt;
* Development subforum on Spectrum Computing https://spectrumcomputing.co.uk/forums/viewforum.php?f=6&lt;br /&gt;
* Blogpost on ZX Spectrum coding from a X86 coder's perspective on superogue's sizecdoing blog http://marquee.revival-studios.com/blog/blog_fluxus.html&lt;br /&gt;
* Easy to read list of all Z80 instructions (including undocumented ones) with size and timing information https://clrhome.org/table/&lt;br /&gt;
* Detailed information on the screen layout http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout/ http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout-part-two/ and http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout-part-three/&lt;br /&gt;
&lt;br /&gt;
=== Small demos with documented source code ===&lt;br /&gt;
* Ceci N'est Pas Un Cube by Ate Bit https://www.pouet.net/prod.php?which=29691&lt;br /&gt;
* Zxwister by Ate Bit https://www.pouet.net/prod.php?which=44123&lt;br /&gt;
* Muse by Ate Bit https://www.pouet.net/prod.php?which=62880&lt;br /&gt;
* Starlet Guitarlet by HOOY-PROGRAM https://www.pouet.net/prod.php?which=52553&lt;br /&gt;
* Clangers On The Dancefloor by HOOY-PROGRAM https://www.pouet.net/prod.php?which=29696&lt;br /&gt;
* Chessington World Of Adventure by HOOY-PROGRAM https://www.pouet.net/prod.php?which=76074&lt;br /&gt;
* Roll Me Gently by Joker https://www.pouet.net/prod.php?which=86338&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=ZX_Spectrum&amp;diff=1866</id>
		<title>ZX Spectrum</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=ZX_Spectrum&amp;diff=1866"/>
				<updated>2025-12-15T12:05:40Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== ZX Spectrum  ==&lt;br /&gt;
The ZX Spectrum consists of a Z80A @ 3.5 MHz CPU with either 16k, 48k or 128K of RAM. Most demos are targeted at the Spectrum 128 because it includes more memory, a shadow screen buffer and an AY soundchip. The different models have slightly different timings - this will cause issues if you are doing cycle-exact effects like multi-color.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
Setting up your development platform for the ZX Spectrum is quite easy, first get the following tools:&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/z00m128/sjasmplus/releases/latest SjASMPlus (z00m's fork)] - cross-platform open source assembler with nice macros for creating Binaries, TAP, TRD and SNA snapshot files out of the box, embedded Lua scripting and support for similar CPUs (Z80/R800/Z80N/i8080/LR35902).&lt;br /&gt;
* [https://github.com/EdouardBERGE/rasm/releases/latest Rasm] - extremely fast cross-platform Z80 assembler with many features&lt;br /&gt;
* Pasmo - for the .TAP create. Available at : http://pasmo.speccy.org&lt;br /&gt;
* Emulator(s): I Found [https://www.zophar.net/sinclair/zx-spin.html ZX Sping], [https://sourceforge.net/projects/fuse-emulator/ FUSE], [https://sourceforge.net/projects/unrealspeccyp/ UnrealSpeccy] and [https://www.aptanet.org/eightyone/ EightyOne] to work best for my usecase. Most emulators can read TAP, SNA and TRD files out of the box.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can use the online Bazematic tool to do a lot of the early development at  [https://bazematic.demozoo.org bazematic.demozoo.org]&lt;br /&gt;
&lt;br /&gt;
=== Start values ===&lt;br /&gt;
Upon startup (when called from basic), the following values can assumed:&lt;br /&gt;
&lt;br /&gt;
* The alternate HL register is set to 0x2758&lt;br /&gt;
* IY = 0x5c3a&lt;br /&gt;
* BC = start address&lt;br /&gt;
* A = C&lt;br /&gt;
&lt;br /&gt;
=== Memory Configuration ===&lt;br /&gt;
128K separated to 8 pages (16384 bytes size)&lt;br /&gt;
Default configuration is:&lt;br /&gt;
&lt;br /&gt;
: page 5: $4000-$7fff&lt;br /&gt;
: page 2: $8000-$Bfff&lt;br /&gt;
: page 0: $C000-$Ffff&lt;br /&gt;
&lt;br /&gt;
There are two screens - page 7 and page 5.&lt;br /&gt;
port $7FFD allow to control memory and screens:&lt;br /&gt;
: bits 0-2 - page number mapped to memory at $C0000&lt;br /&gt;
: bit 3 - Select page 5(0) or page 7(1) to be displayed.&lt;br /&gt;
: bit 4 - ROM Select. 0-128K,1-48K&lt;br /&gt;
&lt;br /&gt;
Example of use&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
loop: ei&lt;br /&gt;
 halt&lt;br /&gt;
pg: ld a,$17&lt;br /&gt;
 ld bc,$7ffd&lt;br /&gt;
 out (c),a&lt;br /&gt;
 xor $0A&lt;br /&gt;
 ld (pg+1),a&lt;br /&gt;
... do something with $C000-$DB00&lt;br /&gt;
 jp loop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$17 is use 48K, map page 7&lt;br /&gt;
After xor $0A we'll get value $1D(use 48K ROM, display screen at page 7 and map page5 at $C000).This is so-called &amp;quot;double buffering&amp;quot;.&lt;br /&gt;
See also : https://worldofspectrum.org/faq/reference/128kreference.htm&lt;br /&gt;
&lt;br /&gt;
=== Graphics ===&lt;br /&gt;
Video display on the ZX Spectrum is mostly CPU based with little hardware features. No hardware sprites, no specific text or video modes, only a 256x192 byte screenbuffer with 1bit pixeldata located at $4000 in memory. &lt;br /&gt;
It is ordened a bit strange in 3 sections of 256x64 pixels, then character rows then subrows.&lt;br /&gt;
&lt;br /&gt;
Address = 010RRLLL RRRCCCCC &lt;br /&gt;
&lt;br /&gt;
* where RRRRR is the row number (0..23)&lt;br /&gt;
* CCCCC is the column number (0..31)&lt;br /&gt;
* LLL is the line number within the cell (0..7)&lt;br /&gt;
&lt;br /&gt;
Calculating a screen address from XY coordinates is complicated due to the weird screen layout. In a larger demo you would generate a lookup table - it's usually best to avoid such calculations in small demos, but it can be done in under 30 bytes, eg: http://www.breakintoprogram.co.uk/computers/zx-spectrum/screen-memory-layout&lt;br /&gt;
&lt;br /&gt;
==== Adding Color ====&lt;br /&gt;
The ZX Spectrum has a 32x24 colormap located at $5800 where you can write color information for each 8x8 tile. &lt;br /&gt;
It has has 8 colors (INK and PAPER) with 2 brightness settings that can be set like this.&lt;br /&gt;
&lt;br /&gt;
color = brightness(64) | (PAPER&amp;lt;&amp;lt;3) | INK&lt;br /&gt;
&lt;br /&gt;
Because updating pixel memory can be slow, especially when you are grasping for bytes, some of the tiny intros on the zx spectrum prefer to use the colorram for the effect, sometimes in combination with an overlaying pattern.&lt;br /&gt;
&lt;br /&gt;
==== Border Color ====&lt;br /&gt;
You can set the border color to any of the 8 colors with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld a,0 ; bottom three bits of a contain the color&lt;br /&gt;
out (254),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Getting something on screen using the COLORRAM====&lt;br /&gt;
Now to get something on screen, lets fill our colorram with a simple AND pattern, like so:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
 ld de,5800h&lt;br /&gt;
 ld b,24&lt;br /&gt;
yloop:&lt;br /&gt;
   ld c,32&lt;br /&gt;
xloop:&lt;br /&gt;
   ld a,c&lt;br /&gt;
   and b&lt;br /&gt;
   and 7    ; make sure range is 0..7&lt;br /&gt;
   ld (de),a&lt;br /&gt;
   inc de&lt;br /&gt;
   dec c&lt;br /&gt;
   jr nz,xloop&lt;br /&gt;
djnz yloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using a Backbuffer ====&lt;br /&gt;
While the above code will run fine, you might want to consider using a backbuffer for more complex stuff. You can then simply write to another adress define by BACKBUFFER (for example A000) and copy the buffer to colorram like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
halt               ; synchronize &lt;br /&gt;
ld hl,BACKBUFFER   &lt;br /&gt;
ld de,5800h&lt;br /&gt;
ld bc,768&lt;br /&gt;
ldir&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another alternative method is to use the 128's memory paging, which provides a second screen buffer. This buffer is located at a different memeory location, but otherwise it is the same:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
	; main loop starts here&lt;br /&gt;
	ld	a,00010111b	; set up memory banks and screen here&lt;br /&gt;
mainloop&lt;br /&gt;
	halt			; sync&lt;br /&gt;
	xor	00001010b	; flip screens&lt;br /&gt;
	out	($fd),a&lt;br /&gt;
	push	af&lt;br /&gt;
&lt;br /&gt;
	; render code goes here&lt;br /&gt;
	; screen buffer is location at 0xC000 instead of 0x4000&lt;br /&gt;
&lt;br /&gt;
	pop	af&lt;br /&gt;
	jr	mainloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Overlaying simple character/pixel graphics ====&lt;br /&gt;
If you don't want to use a solid color/tile for. &lt;br /&gt;
You could copy a single tile across the screen at startup for some flair.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
   ld a,0x55   ; 01010101 pattern&lt;br /&gt;
   ld bc,0x1800&lt;br /&gt;
copyloop:&lt;br /&gt;
   ld (de),a&lt;br /&gt;
   inc de&lt;br /&gt;
   dec c&lt;br /&gt;
jr nz,copyloop&lt;br /&gt;
djnz copyloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could generate a pattern using predefined data, logic operations or random noise/data.&lt;br /&gt;
&lt;br /&gt;
==== General pixel plot routine ====&lt;br /&gt;
Here is a generalised pixel-plot routine provided by Baze:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld   h,TAB&lt;br /&gt;
ld   l,b     ; L = Y&lt;br /&gt;
ld   d,(hl)  ; pick 0 1 0 y7 y6 y2 y1 y0&lt;br /&gt;
inc  h&lt;br /&gt;
ld   h,(hl)  ; depending on y5 y4 y3, pick one of eight sub-tables&lt;br /&gt;
ld   l,c     ; L = X&lt;br /&gt;
ld   e,(hl)  ; pick y5 y4 y3 x7 x6 x5 x4 x3&lt;br /&gt;
inc  h&lt;br /&gt;
ld   a,(de)&lt;br /&gt;
or   (hl)    ; pixel mask 0b1000000 &amp;gt;&amp;gt; (X &amp;amp; 7)&lt;br /&gt;
ld   (de),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ROM Routines ===&lt;br /&gt;
Alternatively you can use the built-in, but very slow, ROM routines to plot pixels and some other primitives:&lt;br /&gt;
&lt;br /&gt;
Calculate Pixel coordinate&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;IN: A=X coordinate,C=L=Y coordinate&lt;br /&gt;
;OUT: HL=screen address,A=bit value&lt;br /&gt;
call #22B0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;write pixel&lt;br /&gt;
 CALL  8933 ; C=X(0..255),B=Y(0..175),5C7D=COORDS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Other Useful routines ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;calculate address of next line,HL=address&lt;br /&gt;
down_hl:&lt;br /&gt;
 INC h&lt;br /&gt;
 LD A,h&lt;br /&gt;
 AND 7&lt;br /&gt;
 RET NZ&lt;br /&gt;
 LD A,L&lt;br /&gt;
 ADD A,#20&lt;br /&gt;
 LD L,A&lt;br /&gt;
 RET C&lt;br /&gt;
 LD A,H&lt;br /&gt;
 SUB 8&lt;br /&gt;
 LD H,A&lt;br /&gt;
 RET&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;move up at screen, HL=address&lt;br /&gt;
up_hl&lt;br /&gt;
     LD A,H&lt;br /&gt;
     DEC H&lt;br /&gt;
     AND 7&lt;br /&gt;
     ret nz&lt;br /&gt;
     LD A,L&lt;br /&gt;
     SUB 32&lt;br /&gt;
     LD L,A&lt;br /&gt;
     ret c&lt;br /&gt;
     LD A,H&lt;br /&gt;
     ADD A,8&lt;br /&gt;
     LD H,A&lt;br /&gt;
 ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;Calculate vertical line screen Address, IN : A=Y coordinate, OUT : HL=address&lt;br /&gt;
py2saddr:&lt;br /&gt;
        ld l,a&lt;br /&gt;
;	ld a,l&lt;br /&gt;
	and $07&lt;br /&gt;
	ld h,a&lt;br /&gt;
	ld a,l&lt;br /&gt;
	and $c0&lt;br /&gt;
	rra&lt;br /&gt;
	inc a&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	or h&lt;br /&gt;
	ld h,a&lt;br /&gt;
	ld a,l&lt;br /&gt;
	add a&lt;br /&gt;
	add a&lt;br /&gt;
	and $e0&lt;br /&gt;
	ld l,a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;Calculate Attribute address, IB: reg D=Y,reg E=X, OUT: HL=address, destroys DE&lt;br /&gt;
 ld l,d&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 ld h,$11&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 add hl,hl&lt;br /&gt;
 ld d,0&lt;br /&gt;
 add hl,de&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or alter version&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
;H=Y coordinate,L=X coordinate&lt;br /&gt;
	ld a,h&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	rrca&lt;br /&gt;
	push af&lt;br /&gt;
	and 3&lt;br /&gt;
	add a,$58&lt;br /&gt;
	ld h,a&lt;br /&gt;
	pop af&lt;br /&gt;
	and %11100000&lt;br /&gt;
	add a,l&lt;br /&gt;
	ld l,a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The original Spectrum has only a 1 bit sound capability (BEEP) through its internal speaker.&lt;br /&gt;
Later models included the AY-3-8910 Soundchip which provides 3 channels of PSG sound.&lt;br /&gt;
&lt;br /&gt;
==== Make some noise - Beeper ====&lt;br /&gt;
Setting/toggling bit 4 of port 254 will enable the beeper speaker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
		ld a,$10	;Bit 4 set&lt;br /&gt;
beeploop:	xor $10		;toggle Bit 4&lt;br /&gt;
		out (254),a&lt;br /&gt;
		ld b,90		;wait&lt;br /&gt;
		djnz $&lt;br /&gt;
		jp beeploop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the bottom three bits of port 254 also set the border color (see above).&lt;br /&gt;
&lt;br /&gt;
==== Make some noise - AY ====&lt;br /&gt;
You can access the AY soundchip by outputting to the following ports:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;z80&amp;quot;&amp;gt;&lt;br /&gt;
ld bc,0xfffd&lt;br /&gt;
ld a, ay register number&lt;br /&gt;
out (c),a&lt;br /&gt;
ld b,0xbf	&lt;br /&gt;
ld a, data byte&lt;br /&gt;
out (c),a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information about the soundchip, check out:&lt;br /&gt;
https://www.atarimagazines.com/v4n7/stsound.html&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
I found resources on ZX Spectrum sizecoding to be sparse.&lt;br /&gt;
* All kinds of Z80 Information http://www.z80.info/index.htm&lt;br /&gt;
* Another source for good Z80 Information http://z80-heaven.wikidot.com&lt;br /&gt;
* Assembler subforum on world of spectrum https://worldofspectrum.org/forums/categories/assembler&lt;br /&gt;
* Development subforum on Spectrum Computing https://spectrumcomputing.co.uk/forums/viewforum.php?f=6&lt;br /&gt;
* Blogpost on ZX Spectrum coding from a X86 coder's perspective on superogue's sizecdoing blog http://marquee.revival-studios.com/blog/blog_fluxus.html&lt;br /&gt;
* Easy to read list of all Z80 instructions (including undocumented ones) with size and timing information https://clrhome.org/table/&lt;br /&gt;
* Detailed information on the screen layout http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout/ http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout-part-two/ and http://www.overtakenbyevents.com/lets-talk-about-the-zx-specrum-screen-layout-part-three/&lt;br /&gt;
&lt;br /&gt;
=== Small demos with documented source code ===&lt;br /&gt;
* Ceci N'est Pas Un Cube by Ate Bit https://www.pouet.net/prod.php?which=29691&lt;br /&gt;
* Zxwister by Ate Bit https://www.pouet.net/prod.php?which=44123&lt;br /&gt;
* Muse by Ate Bit https://www.pouet.net/prod.php?which=62880&lt;br /&gt;
* Starlet Guitarlet by HOOY-PROGRAM https://www.pouet.net/prod.php?which=52553&lt;br /&gt;
* Clangers On The Dancefloor by HOOY-PROGRAM https://www.pouet.net/prod.php?which=29696&lt;br /&gt;
* Chessington World Of Adventure by HOOY-PROGRAM https://www.pouet.net/prod.php?which=76074&lt;br /&gt;
* Roll Me Gently by Joker https://www.pouet.net/prod.php?which=86338&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1865</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1865"/>
				<updated>2025-12-13T13:53:49Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Welcome to SizeCoding.org! ==&lt;br /&gt;
&lt;br /&gt;
'''SizeCoding.org''' is a wiki dedicated to teaching programmers the various techniques used to create [https://nanogems.demozoo.org/ tiny demoscene intros]. While these techniques can be used for other applications (boot sectors, ROM, BIOS and firmware code, etc.), the information presented here is firmly oriented towards the [https://en.wikipedia.org/wiki/Demoscene demoscene]. Practicality and common sense are sometimes thrown out the window just to shave a single byte.&lt;br /&gt;
&lt;br /&gt;
For those unfamiliar with the demoscene or demoscene effects, here is:&lt;br /&gt;
*'''[https://nanogems.demozoo.org/ A curated collection of the best Tiny Intros from the Demoscene]''' &lt;br /&gt;
*'''[[Design Tips and Demoscene effects with pseudo code]]'''&lt;br /&gt;
*'''[[Information about demoscene parties]]'''&lt;br /&gt;
&lt;br /&gt;
Now with that said, here is the list of active platforms available on this wiki:&lt;br /&gt;
&lt;br /&gt;
'''Oldschool 8-bit / 16-bit platforms:'''&lt;br /&gt;
*'''[[Motorola 68000]]''' - [[Commodore_Amiga]], [[Atari_ST]], [[Sinclair_QL]], [[X68000]], etc.&lt;br /&gt;
*'''[[6502]]''' - [[Commodore_64]], [[Atari_8bit]], [[Apple_II]], [[Atari_Lynx]], [[BBC_Micro]], etc.&lt;br /&gt;
*'''[[Z80]]''' - [[ZX_Spectrum]], [[Amstrad_CPC]], etc.&lt;br /&gt;
*'''[[6809]]''' - Dragon 32/64, Tandy CoCo, Vectrex, etc.&lt;br /&gt;
*'''[[PDP-11]]''' - BK-0010 / BK-0011, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''As well as modern platforms like:'''&lt;br /&gt;
*'''[[Fantasy consoles]]''' - [[TIC-80]], [[PICO-8]], [[MicroW8]]&lt;br /&gt;
*'''[[Windows]]''' - Sizecoding for [[Windows_Tiny_Intro]], [[1K_Intro]] and [[4K_Intro]].&lt;br /&gt;
*'''[[DOS]]''' - Sizecoding for X86 / DOS.&lt;br /&gt;
*'''[[Javascript]]''' - Sizecoding for Browsers / JavaScript&lt;br /&gt;
*'''[[Processing]]''' - Sizecoding using Processing&lt;br /&gt;
*'''[[Linux]]''' - Sizecoding for Linux.&lt;br /&gt;
*'''[[ARM]]''' - ARM-based platforms (RISC OS, Acorn Archimedes, Gameboy Advance, etc.)&lt;br /&gt;
*'''[[RISC-V]]''' - RISC−V micro-processors. &lt;br /&gt;
*'''[[ReGIS]]''' - VT125, VT230, VT240/241 and more terminal display vector graphics language.&lt;br /&gt;
*'''[[Bytebeat]]''' - Tiny music created from mathematical expressions.&lt;br /&gt;
&lt;br /&gt;
By &amp;quot;very tiny programs&amp;quot;, we usually mean programs that are '''1024 bytes or less in size''', typically created by members of the [https://en.wikipedia.org/wiki/Demoscene demoscene] as a show of programming skill. In other scenes this artform is sometimes also known as generative , codeart , proceduralart , generativeart , codegolfing , codegolf , tweetcart dwitter , twigl and tweetjam.&lt;br /&gt;
&lt;br /&gt;
The size of these tiny programs is measured by their total size in opcode bytes, and are usually presented as an executable binary. Despite their tiny size, these programs are able to produce amazing graphical displays, playable games, and sometimes music. There are even some surprisingly effective programs in just '''16 bytes'''  [https://demozoo.org/productions/?platform=&amp;amp;production_type=55] or even '''8 bytes''' [https://demozoo.org/productions/?platform=&amp;amp;production_type=54].&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sinclair_QL&amp;diff=1864</id>
		<title>Sinclair QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sinclair_QL&amp;diff=1864"/>
				<updated>2025-12-06T13:22:51Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sinclair QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): Mdvtool (create MDV images)&lt;br /&gt;
* Hardware: Sinclair QL machine or Spectrum Next running the QL core&lt;br /&gt;
&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, create a file called BOOT in the output folder with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MDV1_CODE&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
 move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
 tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
 beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
 move.l  #$20000,screenpointer1&lt;br /&gt;
 move.l  #$28000,screenpointer2&lt;br /&gt;
 move.b  #8,scr&lt;br /&gt;
 move.b  #0,scr+1&lt;br /&gt;
 move.b  #8,$18063&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
 lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
 move.l  (a0),d0         ; save it&lt;br /&gt;
 move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
 move.l  d0,(a0)         ; write back&lt;br /&gt;
 lea     scr,a0          ; get flipbit&lt;br /&gt;
 move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
 eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
scr: dc.b    8,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 lea $28000,a0       ; screen2&lt;br /&gt;
 lea $20000,a1       ; screen1	&lt;br /&gt;
 move.l a0,a2&lt;br /&gt;
 move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
 move.l   (a2),(a1)+&lt;br /&gt;
 clr.l   (a2)+&lt;br /&gt;
 dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Sinclair_QL&amp;diff=1863</id>
		<title>Sinclair QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Sinclair_QL&amp;diff=1863"/>
				<updated>2025-12-06T13:22:32Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: Created page with &amp;quot;== Spectrum QL == The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum. It was aimed...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): Mdvtool (create MDV images)&lt;br /&gt;
* Hardware: Sinclair QL machine or Spectrum Next running the QL core&lt;br /&gt;
&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, create a file called BOOT in the output folder with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MDV1_CODE&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
 move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
 tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
 beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
 move.l  #$20000,screenpointer1&lt;br /&gt;
 move.l  #$28000,screenpointer2&lt;br /&gt;
 move.b  #8,scr&lt;br /&gt;
 move.b  #0,scr+1&lt;br /&gt;
 move.b  #8,$18063&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
 lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
 move.l  (a0),d0         ; save it&lt;br /&gt;
 move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
 move.l  d0,(a0)         ; write back&lt;br /&gt;
 lea     scr,a0          ; get flipbit&lt;br /&gt;
 move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
 eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
scr: dc.b    8,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 lea $28000,a0       ; screen2&lt;br /&gt;
 lea $20000,a1       ; screen1	&lt;br /&gt;
 move.l a0,a2&lt;br /&gt;
 move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
 move.l   (a2),(a1)+&lt;br /&gt;
 clr.l   (a2)+&lt;br /&gt;
 dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1862</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Main_Page&amp;diff=1862"/>
				<updated>2025-12-06T13:22:11Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Welcome to SizeCoding.org! ==&lt;br /&gt;
&lt;br /&gt;
'''SizeCoding.org''' is a wiki dedicated to teaching programmers the various techniques used to create [https://nanogems.demozoo.org/ tiny demoscene intros]. While these techniques can be used for other applications (boot sectors, ROM, BIOS and firmware code, etc.), the information presented here is firmly oriented towards the [https://en.wikipedia.org/wiki/Demoscene demoscene]. Practicality and common sense are sometimes thrown out the window just to shave a single byte.&lt;br /&gt;
&lt;br /&gt;
For those unfamiliar with the demoscene or demoscene effects, here is:&lt;br /&gt;
*'''[https://nanogems.demozoo.org/ A curated collection of the best Tiny Intros from the Demoscene]''' &lt;br /&gt;
*'''[[Design Tips and Demoscene effects with pseudo code]]'''&lt;br /&gt;
*'''[[Information about demoscene parties]]'''&lt;br /&gt;
&lt;br /&gt;
Now with that said, here is the list of active platforms available on this wiki:&lt;br /&gt;
&lt;br /&gt;
'''Oldschool 8-bit / 16-bit platforms:'''&lt;br /&gt;
*'''[[Motorola 68000]]''' - [[Commodore_Amiga]], [[Atari_ST]], [[Sinclair_QL]], [[X68000]], etc.&lt;br /&gt;
*'''[[6502]]''' - Commodore 64, Atari XE/XL, Apple II, Atari Lynx, BBC Micro, etc.&lt;br /&gt;
*'''[[Z80]]''' - ZX Spectrum, Amstrad CPC, etc.&lt;br /&gt;
*'''[[6809]]''' - Dragon 32/64, Tandy CoCo, Vectrex, etc.&lt;br /&gt;
*'''[[PDP-11]]''' - BK-0010 / BK-0011, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''As well as modern platforms like:'''&lt;br /&gt;
*'''[[Fantasy consoles]]''' - [[TIC-80]], [[PICO-8]], [[MicroW8]]&lt;br /&gt;
*'''[[Windows]]''' - Sizecoding for Windows: 1K and 4K intros.&lt;br /&gt;
*'''[[DOS]]''' - Sizecoding for X86 / DOS.&lt;br /&gt;
*'''[[Javascript]]''' - Sizecoding for Browsers / JavaScript&lt;br /&gt;
*'''[[Processing]]''' - Sizecoding using Processing&lt;br /&gt;
*'''[[Linux]]''' - Sizecoding for Linux.&lt;br /&gt;
*'''[[ARM]]''' - ARM-based platforms (RISC OS, Acorn Archimedes, Gameboy Advance, etc.)&lt;br /&gt;
*'''[[RISC-V]]''' - RISC−V micro-processors. &lt;br /&gt;
*'''[[ReGIS]]''' - VT125, VT230, VT240/241 and more terminal display vector graphics language.&lt;br /&gt;
*'''[[Bytebeat]]''' - Tiny music created from mathematical expressions.&lt;br /&gt;
&lt;br /&gt;
By &amp;quot;very tiny programs&amp;quot;, we usually mean programs that are '''1024 bytes or less in size''', typically created by members of the [https://en.wikipedia.org/wiki/Demoscene demoscene] as a show of programming skill. In other scenes this artform is sometimes also known as generative , codeart , proceduralart , generativeart , codegolfing , codegolf , tweetcart dwitter , twigl and tweetjam.&lt;br /&gt;
&lt;br /&gt;
The size of these tiny programs is measured by their total size in opcode bytes, and are usually presented as an executable binary. Despite their tiny size, these programs are able to produce amazing graphical displays, playable games, and sometimes music. There are even some surprisingly effective programs in just '''16 bytes'''  [https://demozoo.org/productions/?platform=&amp;amp;production_type=55] or even '''8 bytes''' [https://demozoo.org/productions/?platform=&amp;amp;production_type=54].&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1861</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1861"/>
				<updated>2025-12-02T09:32:53Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
* Hardware: Original X68000 or the new X68000Z emulation systems.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Disk Image ===&lt;br /&gt;
To get up and running, you need to create a Human68k OS XDF disk image, which is a similar system to MS-DOS.&lt;br /&gt;
&lt;br /&gt;
Add the following files to the disk image:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
COMMAND.X&lt;br /&gt;
HUMAN.SYS&lt;br /&gt;
INTRO.R  (This is the flat binary output for your intro)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Optionally, like in DOS, you can add a AUTOEXEC.BAT that just launches your INTRO.R for auto-startup.&lt;br /&gt;
&lt;br /&gt;
=== Setting the Supervisor ===&lt;br /&gt;
Like all 68000 systems, if you want to access registers, you need to set the supervisor mode first before doing anything else:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
clr.l -(a7)&lt;br /&gt;
dc.w $ff20&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
; The text palette is initialized.&lt;br /&gt;
moveq #10,d1    &lt;br /&gt;
moveq #$10,d0&lt;br /&gt;
trap #15 &lt;br /&gt;
  &lt;br /&gt;
; Enable graphics mode &lt;br /&gt;
; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
move.w #$90,d0&lt;br /&gt;
trap #15   &lt;br /&gt;
&lt;br /&gt;
; Disable Text Cursor&lt;br /&gt;
moveq #$1f,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Double buffering ====&lt;br /&gt;
You can use the following IOCS routines to set the active drawing and screenpages for double buffering.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; APAGE: Graphic drawing page settings&lt;br /&gt;
move.w #$b1,d0&lt;br /&gt;
moveq #0,d1  ; set page 0..3&lt;br /&gt;
trap #15&lt;br /&gt;
&lt;br /&gt;
; VPAGE: Graphic screen display page setting&lt;br /&gt;
move.w #$b2,d0&lt;br /&gt;
moveq #0,d1  ; set page 0..3&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active page using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS drawing routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots. There are a total of 32 slots that can be turned on or off when the sound is triggered. For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
Alternatively, there is also an option to output digital PCM sound.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1860</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1860"/>
				<updated>2025-12-02T09:27:57Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
* Hardware: Original X68000 or the new X68000Z emulation systems.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Disk Image ===&lt;br /&gt;
To get up and running, you need to create a Human68k OS XDF disk image, which is a similar system to MS-DOS.&lt;br /&gt;
&lt;br /&gt;
Add the following files to the disk image:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
COMMAND.X&lt;br /&gt;
HUMAN.SYS&lt;br /&gt;
INTRO.R  (This is the flat binary output for your intro)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Optionally, like in DOS, you can add a AUTOEXEC.BAT that just launches your INTRO.R for auto-startup.&lt;br /&gt;
&lt;br /&gt;
=== Setting the Supervisor ===&lt;br /&gt;
Like all 68000 systems, if you want to access registers, you need to set the supervisor mode first before doing anything else:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
clr.l -(a7)&lt;br /&gt;
dc.w $ff20&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
; The text palette is initialized.&lt;br /&gt;
moveq #10,d1    &lt;br /&gt;
moveq #$10,d0&lt;br /&gt;
trap #15 &lt;br /&gt;
  &lt;br /&gt;
; Enable graphics mode &lt;br /&gt;
; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
move.w #$90,d0&lt;br /&gt;
trap #15   &lt;br /&gt;
&lt;br /&gt;
; Disable Text Cursor&lt;br /&gt;
moveq #$1f,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS drawing routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots. There are a total of 32 slots that can be turned on or off when the sound is triggered. For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
Alternatively, there is also an option to output digital PCM sound.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1859</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1859"/>
				<updated>2025-12-02T09:25:43Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): Mdvtool (create MDV images)&lt;br /&gt;
* Hardware: Sinclair QL machine or Spectrum Next running the QL core&lt;br /&gt;
&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, create a file called BOOT in the output folder with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MDV1_CODE&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
 move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
 tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
 beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
 move.l  #$20000,screenpointer1&lt;br /&gt;
 move.l  #$28000,screenpointer2&lt;br /&gt;
 move.b  #8,scr&lt;br /&gt;
 move.b  #0,scr+1&lt;br /&gt;
 move.b  #8,$18063&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
 lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
 move.l  (a0),d0         ; save it&lt;br /&gt;
 move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
 move.l  d0,(a0)         ; write back&lt;br /&gt;
 lea     scr,a0          ; get flipbit&lt;br /&gt;
 move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
 eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
scr: dc.b    8,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 lea $28000,a0       ; screen2&lt;br /&gt;
 lea $20000,a1       ; screen1	&lt;br /&gt;
 move.l a0,a2&lt;br /&gt;
 move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
 move.l   (a2),(a1)+&lt;br /&gt;
 clr.l   (a2)+&lt;br /&gt;
 dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1858</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1858"/>
				<updated>2025-12-02T09:25:02Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): Mdvtool (create MDV images)&lt;br /&gt;
* Hardware: Sinclair QL machine or Spectrum Next running the QL core&lt;br /&gt;
&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, create a file called BOOT in the output folder with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MDV1_CODE&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
 move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
 tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
 beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
 move.l  #$20000,screenpointer1&lt;br /&gt;
 move.l  #$28000,screenpointer2&lt;br /&gt;
 move.b  #8,scr&lt;br /&gt;
 move.b  #0,scr+1&lt;br /&gt;
 move.b  #8,$18063&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
 lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
 move.l  (a0),d0         ; save it&lt;br /&gt;
 move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
 move.l  d0,(a0)         ; write back&lt;br /&gt;
 lea     scr,a0          ; get flipbit&lt;br /&gt;
 move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
 eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
 rts&lt;br /&gt;
&lt;br /&gt;
scr: dc.b    8,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 lea $28000,a0       ; screen2&lt;br /&gt;
 lea $20000,a1       ; screen1	&lt;br /&gt;
 move.l a0,a2&lt;br /&gt;
 move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
 move.l   (a2),(a1)+&lt;br /&gt;
 clr.l   (a2)+&lt;br /&gt;
 dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1857</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1857"/>
				<updated>2025-12-02T09:21:53Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
* Hardware: Original X68000 or the new X68000Z emulation systems.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Disk Image ===&lt;br /&gt;
To get up and running, you need to create a Human68k OS XDF disk image, which is a similar system to MS-DOS.&lt;br /&gt;
&lt;br /&gt;
Add the following files to the disk image:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
COMMAND.X&lt;br /&gt;
HUMAN.SYS&lt;br /&gt;
INTRO.R  (This is the flat binary output for your intro)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Optionally, like in DOS, you can add a AUTOEXEC.BAT that just launches your INTRO.R for auto-startup.&lt;br /&gt;
&lt;br /&gt;
=== Setting the Supervisor ===&lt;br /&gt;
Like all 68000 systems, if you want to access registers, you need to set the supervisor mode first before doing anything else:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
clr.l -(a7)&lt;br /&gt;
dc.w $ff20&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
; The text palette is initialized.&lt;br /&gt;
moveq #10,d1    &lt;br /&gt;
moveq #$10,d0&lt;br /&gt;
trap #15 &lt;br /&gt;
  &lt;br /&gt;
; Enable graphics mode &lt;br /&gt;
; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
move.w #$90,d0&lt;br /&gt;
trap #15   &lt;br /&gt;
&lt;br /&gt;
; Disable Text Cursor&lt;br /&gt;
moveq #$1f,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots. There are a total of 32 slots that can be turned on or off when the sound is triggered. For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
Alternatively, there is also an option to output digital PCM sound.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1856</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1856"/>
				<updated>2025-12-02T09:15:22Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
* Hardware: Original X68000 or the new X68000Z emulation systems.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setting the Supervisor ===&lt;br /&gt;
Like all 68000 systems, if you want to access registers, you need to set the supervisor mode first before doing anything else:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
clr.l -(a7)&lt;br /&gt;
dc.w $ff20&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
; The text palette is initialized.&lt;br /&gt;
moveq #10,d1    &lt;br /&gt;
moveq #$10,d0&lt;br /&gt;
trap #15 &lt;br /&gt;
  &lt;br /&gt;
; Enable graphics mode &lt;br /&gt;
; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
move.w #$90,d0&lt;br /&gt;
trap #15   &lt;br /&gt;
&lt;br /&gt;
; Disable Text Cursor&lt;br /&gt;
moveq #$1f,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots. There are a total of 32 slots that can be turned on or off when the sound is triggered. For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
Alternatively, there is also an option to output digital PCM sound.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1855</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1855"/>
				<updated>2025-12-02T09:14:13Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Setting the Supervisor ===&lt;br /&gt;
Like all 68000 systems, if you want to access registers, you need to set the supervisor mode first before doing anything else:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
clr.l -(a7)&lt;br /&gt;
dc.w $ff20&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
; The text palette is initialized.&lt;br /&gt;
moveq #10,d1    &lt;br /&gt;
moveq #$10,d0&lt;br /&gt;
trap #15 &lt;br /&gt;
  &lt;br /&gt;
; Enable graphics mode &lt;br /&gt;
; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
move.w #$90,d0&lt;br /&gt;
trap #15   &lt;br /&gt;
&lt;br /&gt;
; Disable Text Cursor&lt;br /&gt;
moveq #$1f,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots. There are a total of 32 slots that can be turned on or off when the sound is triggered. For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
Alternatively, there is also an option to output digital PCM sound.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1854</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1854"/>
				<updated>2025-12-02T09:11:20Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
; The text palette is initialized.&lt;br /&gt;
moveq #10,d1    &lt;br /&gt;
moveq #$10,d0&lt;br /&gt;
trap #15 &lt;br /&gt;
  &lt;br /&gt;
; Enable graphics mode &lt;br /&gt;
; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
move.w #$90,d0&lt;br /&gt;
trap #15   &lt;br /&gt;
&lt;br /&gt;
; Disable Text Cursor&lt;br /&gt;
moveq #$1f,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots. There are a total of 32 slots that can be turned on or off when the sound is triggered. For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
Alternatively, there is also an option to output digital PCM sound.&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1853</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1853"/>
				<updated>2025-12-02T09:09:40Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
; The text palette is initialized.&lt;br /&gt;
moveq #10,d1    &lt;br /&gt;
moveq #$10,d0&lt;br /&gt;
trap #15 &lt;br /&gt;
  &lt;br /&gt;
; Enable graphics mode &lt;br /&gt;
; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
move.w #$90,d0&lt;br /&gt;
trap #15   &lt;br /&gt;
&lt;br /&gt;
; Disable Text Cursor&lt;br /&gt;
moveq #$1f,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots'... meaning there are a total of 32 slots... these slots are turned on or off when the sound is triggered&lt;br /&gt;
&lt;br /&gt;
For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1852</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1852"/>
				<updated>2025-12-02T09:09:10Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 ; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
 ; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
 ; The text palette is initialized.&lt;br /&gt;
 moveq #10,d1    &lt;br /&gt;
 moveq #$10,d0&lt;br /&gt;
 trap #15 &lt;br /&gt;
  &lt;br /&gt;
 ; Enable graphics mode &lt;br /&gt;
 ; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
 ; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
 move.w #$90,d0&lt;br /&gt;
 trap #15   &lt;br /&gt;
&lt;br /&gt;
 ; Disable Text Cursor&lt;br /&gt;
 moveq #$1f,d0&lt;br /&gt;
 trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea params,a1&lt;br /&gt;
move.w d2,(a1)    ; x-coord&lt;br /&gt;
move.w d3,2(a1)   ; y-coord &lt;br /&gt;
move.w #255,4(a1) ; color&lt;br /&gt;
move.l #_PSET,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots'... meaning there are a total of 32 slots... these slots are turned on or off when the sound is triggered&lt;br /&gt;
&lt;br /&gt;
For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1851</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1851"/>
				<updated>2025-12-02T09:08:50Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 ; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
 ; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
 ; The text palette is initialized.&lt;br /&gt;
 moveq #10,d1    &lt;br /&gt;
 moveq #$10,d0&lt;br /&gt;
 trap #15 &lt;br /&gt;
  &lt;br /&gt;
 ; Enable graphics mode &lt;br /&gt;
 ; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
 ; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
 move.w #$90,d0&lt;br /&gt;
 trap #15   &lt;br /&gt;
&lt;br /&gt;
 ; Disable Text Cursor&lt;br /&gt;
 moveq #$1f,d0&lt;br /&gt;
 trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.w #$b5,d0&lt;br /&gt;
trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea params,a1&lt;br /&gt;
    move.w d2,(a1)    ; x-coord&lt;br /&gt;
    move.w d3,2(a1)   ; y-coord &lt;br /&gt;
    move.w #255,4(a1) ; color&lt;br /&gt;
    move.l #_PSET,d0&lt;br /&gt;
    trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots'... meaning there are a total of 32 slots... these slots are turned on or off when the sound is triggered&lt;br /&gt;
&lt;br /&gt;
For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1850</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1850"/>
				<updated>2025-12-02T09:08:00Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 ; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
 ; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
 ; The text palette is initialized.&lt;br /&gt;
 moveq #10,d1    &lt;br /&gt;
 moveq #$10,d0&lt;br /&gt;
 trap #15 &lt;br /&gt;
  &lt;br /&gt;
 ; Enable graphics mode &lt;br /&gt;
 ; _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
 ; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
 move.w #$90,d0&lt;br /&gt;
 trap #15   &lt;br /&gt;
&lt;br /&gt;
 ; Disable Text Cursor&lt;br /&gt;
 moveq #$1f,d0&lt;br /&gt;
 trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
You can Clear the active screen using the WIPE IOCS routine ($b5)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.w #$b5,d0&lt;br /&gt;
 trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
move.w #256,d7&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea params,a1&lt;br /&gt;
    move.w d2,(a1)    ; x-coord&lt;br /&gt;
    move.w d3,2(a1)   ; y-coord &lt;br /&gt;
    move.w #255,4(a1) ; color&lt;br /&gt;
    move.l #_PSET,d0&lt;br /&gt;
    trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots'... meaning there are a total of 32 slots... these slots are turned on or off when the sound is triggered&lt;br /&gt;
&lt;br /&gt;
For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1849</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1849"/>
				<updated>2025-12-02T09:03:21Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
To get your video mode up and running, there are two call you need to make in a specific order&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  ; Set CRT mode. Clears plane 0/1 on the text screen to set display mode.&lt;br /&gt;
  ; The graphics screen and sprite screen are put into silent mode without being cleared.&lt;br /&gt;
  ; The text palette is initialized.&lt;br /&gt;
  moveq #10,d1    &lt;br /&gt;
  moveq #$10,d0&lt;br /&gt;
  trap #15 &lt;br /&gt;
  &lt;br /&gt;
  ; Enable graphics mode &lt;br /&gt;
  ; $90 _G_CLR_ON Initializes the graphic screen and sets the display mode&lt;br /&gt;
  ; Clears the graphics screen and displays the palette. The page is set to 0.&lt;br /&gt;
  move.w #$90,d0&lt;br /&gt;
  trap #15   &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of all available graphics modes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	p.width  resolution     colors  screens khz&lt;br /&gt;
=================================================== &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Clearing the screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
lea GVRAM,a0&lt;br /&gt;
moveq d7,a0&lt;br /&gt;
drawloop:&lt;br /&gt;
move.w (a0)+,d0&lt;br /&gt;
dbra d7,drawloop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Since GVRAM buffer widths can differ from the resolution you are using, make sure to skip enough words at the end of each line to make up for the difference.&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives using TRAP #15.&lt;br /&gt;
These are slow tom routines, compatible with all kinds of modes,&lt;br /&gt;
All these make use of a parameter buffer in A1 that you need to fill yourself with the correct information, for example for _PSET this would contain X,Y,COLOR like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea params,a1&lt;br /&gt;
    move.w d2,(a1)    ; x-coord&lt;br /&gt;
    move.w d3,2(a1)   ; y-coord &lt;br /&gt;
    move.w #255,4(a1) ; color&lt;br /&gt;
    move.l #_PSET,d0&lt;br /&gt;
    trap #15&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a full list of other IOCS routines you are able to use.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots'... meaning there are a total of 32 slots... these slots are turned on or off when the sound is triggered&lt;br /&gt;
&lt;br /&gt;
For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1848</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1848"/>
				<updated>2025-12-02T08:47:51Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): Mdvtool (create MDV images)&lt;br /&gt;
* Hardware: Sinclair QL machine or Spectrum Next running the QL core&lt;br /&gt;
&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, create a file called BOOT in the output folder with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MDV1_CODE&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
    move.l  #$20000,screenpointer1&lt;br /&gt;
    move.l  #$28000,screenpointer2&lt;br /&gt;
    move.b  #8,scr&lt;br /&gt;
    move.b  #0,scr+1&lt;br /&gt;
    move.b  #8,$18063&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
    lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
    move.l  (a0),d0         ; save it&lt;br /&gt;
    move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
    move.l  d0,(a0)         ; write back&lt;br /&gt;
    lea     scr,a0          ; get flipbit&lt;br /&gt;
    move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
    eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
scr:            dc.b    8               ;1000&lt;br /&gt;
                dc.b    0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea $28000,a0       ; screen2&lt;br /&gt;
    lea $20000,a1       ; screen1	&lt;br /&gt;
    move.l a0,a2&lt;br /&gt;
    move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
    move.l   (a2),(a1)+&lt;br /&gt;
    clr.l   (a2)+&lt;br /&gt;
    dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1847</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1847"/>
				<updated>2025-12-02T08:47:34Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): Mdvtool (create MDV images)&lt;br /&gt;
* Hardware: Sinclair QL machine or Spectrum Next&lt;br /&gt;
&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, create a file called BOOT in the output folder with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MDV1_CODE&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
    move.l  #$20000,screenpointer1&lt;br /&gt;
    move.l  #$28000,screenpointer2&lt;br /&gt;
    move.b  #8,scr&lt;br /&gt;
    move.b  #0,scr+1&lt;br /&gt;
    move.b  #8,$18063&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
    lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
    move.l  (a0),d0         ; save it&lt;br /&gt;
    move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
    move.l  d0,(a0)         ; write back&lt;br /&gt;
    lea     scr,a0          ; get flipbit&lt;br /&gt;
    move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
    eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
scr:            dc.b    8               ;1000&lt;br /&gt;
                dc.b    0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea $28000,a0       ; screen2&lt;br /&gt;
    lea $20000,a1       ; screen1	&lt;br /&gt;
    move.l a0,a2&lt;br /&gt;
    move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
    move.l   (a2),(a1)+&lt;br /&gt;
    clr.l   (a2)+&lt;br /&gt;
    dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1846</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1846"/>
				<updated>2025-12-02T08:46:58Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC, create a file called BOOT in the output folder with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MDV1_CODE&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now copy your intro code as CODE into the same output folder and Q-Emulator should be able to pick everything up automatically and load the code. You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
    move.l  #$20000,screenpointer1&lt;br /&gt;
    move.l  #$28000,screenpointer2&lt;br /&gt;
    move.b  #8,scr&lt;br /&gt;
    move.b  #0,scr+1&lt;br /&gt;
    move.b  #8,$18063&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
    lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
    move.l  (a0),d0         ; save it&lt;br /&gt;
    move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
    move.l  d0,(a0)         ; write back&lt;br /&gt;
    lea     scr,a0          ; get flipbit&lt;br /&gt;
    move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
    eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
scr:            dc.b    8               ;1000&lt;br /&gt;
                dc.b    0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea $28000,a0       ; screen2&lt;br /&gt;
    lea $20000,a1       ; screen1	&lt;br /&gt;
    move.l a0,a2&lt;br /&gt;
    move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
    move.l   (a2),(a1)+&lt;br /&gt;
    clr.l   (a2)+&lt;br /&gt;
    dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1845</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1845"/>
				<updated>2025-12-02T08:41:07Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 trap #0&lt;br /&gt;
 ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
    move.l  #$20000,screenpointer1&lt;br /&gt;
    move.l  #$28000,screenpointer2&lt;br /&gt;
    move.b  #8,scr&lt;br /&gt;
    move.b  #0,scr+1&lt;br /&gt;
    move.b  #8,$18063&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
    lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
    move.l  (a0),d0         ; save it&lt;br /&gt;
    move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
    move.l  d0,(a0)         ; write back&lt;br /&gt;
    lea     scr,a0          ; get flipbit&lt;br /&gt;
    move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
    eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
scr:            dc.b    8               ;1000&lt;br /&gt;
                dc.b    0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea $28000,a0       ; screen2&lt;br /&gt;
    lea $20000,a1       ; screen1	&lt;br /&gt;
    move.l a0,a2&lt;br /&gt;
    move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
    move.l   (a2),(a1)+&lt;br /&gt;
    clr.l   (a2)+&lt;br /&gt;
    dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1844</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1844"/>
				<updated>2025-12-02T08:40:40Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Before using Screen2 ====&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    trap #0&lt;br /&gt;
    ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
    move.l  #$20000,screenpointer1&lt;br /&gt;
    move.l  #$28000,screenpointer2&lt;br /&gt;
    move.b  #8,scr&lt;br /&gt;
    move.b  #0,scr+1&lt;br /&gt;
    move.b  #8,$18063&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
    lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
    move.l  (a0),d0         ; save it&lt;br /&gt;
    move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
    move.l  d0,(a0)         ; write back&lt;br /&gt;
    lea     scr,a0          ; get flipbit&lt;br /&gt;
    move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
    eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
scr:            dc.b    8               ;1000&lt;br /&gt;
                dc.b    0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
As an alternative to swapping the screenpointers, here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea $28000,a0       ; screen2&lt;br /&gt;
    lea $20000,a1       ; screen1	&lt;br /&gt;
    move.l a0,a2&lt;br /&gt;
    move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
    move.l   (a2),(a1)+&lt;br /&gt;
    clr.l   (a2)+&lt;br /&gt;
    dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1843</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1843"/>
				<updated>2025-12-02T08:38:55Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
=== Before using Screen2 ===&lt;br /&gt;
Since the Screen2 area is mapped to the system, we need to add the following code at the start of the program to be able&lt;br /&gt;
to make use of it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    trap #0&lt;br /&gt;
    ori #0700,sr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or alternatively move the stack manually &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
 move.l  #$40000-4,sp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Swapping screens ====&lt;br /&gt;
To swap between the two screens via hardware, we need to swap the buffer pointer and set the screen register accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
resetScreens:&lt;br /&gt;
    move.l  #$20000,screenpointer1&lt;br /&gt;
    move.l  #$28000,screenpointer2&lt;br /&gt;
    move.b  #8,scr&lt;br /&gt;
    move.b  #0,scr+1&lt;br /&gt;
    move.b  #8,$18063&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
swapscreens: &lt;br /&gt;
    lea  screenpointer1,a0 ; get screen ptr address&lt;br /&gt;
    move.l  (a0),d0         ; save it&lt;br /&gt;
    move.l  4(a0),(a0)+     ; rotate screenbuffers&lt;br /&gt;
    move.l  d0,(a0)         ; write back&lt;br /&gt;
    lea     scr,a0          ; get flipbit&lt;br /&gt;
    move.b  (a0),$18063     ; write flipbit&lt;br /&gt;
    eor.b   #128,(a0)       ; flip the bit&lt;br /&gt;
    rts&lt;br /&gt;
&lt;br /&gt;
scr:            dc.b    8               ;1000&lt;br /&gt;
                dc.b    0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Copying and clearing the screen ====&lt;br /&gt;
Here is some compact, but slow, code to copy over the contents from screen2 to screen1 and clear the screen2.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
    lea $28000,a0       ; screen2&lt;br /&gt;
    lea $20000,a1       ; screen1	&lt;br /&gt;
    move.l a0,a2&lt;br /&gt;
    move.w  #256*32,d0&lt;br /&gt;
swappage: &lt;br /&gt;
    move.l   (a2),(a1)+&lt;br /&gt;
    clr.l   (a2)+&lt;br /&gt;
    dbf     d0,swappage&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1842</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1842"/>
				<updated>2025-11-29T12:27:37Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
Here is a list of graphics modes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w	 &lt;br /&gt;
0	1024	 512 x 512	16	1	31&lt;br /&gt;
1	V		V	V	V	15&lt;br /&gt;
2	V	 256 x 256	V	V	31&lt;br /&gt;
3	V		V	V	V	15&lt;br /&gt;
4	512	 512 x 512	16	4	31&lt;br /&gt;
5	V		V	V	V	15&lt;br /&gt;
6	V	 256 x 256	V	V	31&lt;br /&gt;
7	V		V	V	V	15&lt;br /&gt;
8	V	 512 x 512	256	2	31&lt;br /&gt;
9	V		V	V	V	15&lt;br /&gt;
10	V	 256 x 256	V	V	31&lt;br /&gt;
11	V		V	V	V	15&lt;br /&gt;
12	V	 512 x 512	65536	1	31&lt;br /&gt;
13	V		V	V	V	15&lt;br /&gt;
14	V	 256 x 256	V	V	31&lt;br /&gt;
15	V		V	V	V	15&lt;br /&gt;
16	1024	 768 x 512	16	1	31&lt;br /&gt;
17	V	1024 x 424	V	V	24&lt;br /&gt;
18	V	1024 x 848	V	V	24&lt;br /&gt;
19	V	 640 x 480	V	V	24&lt;br /&gt;
20	V	 768 x 512	256	2	31&lt;br /&gt;
21	V	1024 x 848	V	V	24&lt;br /&gt;
22	V	1024 x 424	V	V	24&lt;br /&gt;
23	V	 640 x 480	V	V	24&lt;br /&gt;
24	V	 768 x 512	65536	1	31&lt;br /&gt;
25	V	1024 x 848	V	V	24&lt;br /&gt;
26	V	1024 x 424	V	V	24&lt;br /&gt;
27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
When accessing using GRAM directly, you can fill the GVRAM directly in word (64k colors), byte (8 bit palette) or 4-bit 16 color mode.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
To be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== IOCS Drawing routines ====&lt;br /&gt;
Alternatively you could make use of the IOCS functions for drawing primitives.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
_PSET               equ     $b6&lt;br /&gt;
_POINT              equ     $b7&lt;br /&gt;
_LINE               equ     $b8&lt;br /&gt;
_BOX                equ     $b9&lt;br /&gt;
_FILL               equ     $ba&lt;br /&gt;
_CIRCLE             equ     $bb&lt;br /&gt;
_PAINT              equ     $bc&lt;br /&gt;
_SYMBOL             equ     $bd&lt;br /&gt;
_GETGRM             equ     $be&lt;br /&gt;
_PUTGRM             equ     $bf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots'... meaning there are a total of 32 slots... these slots are turned on or off when the sound is triggered&lt;br /&gt;
&lt;br /&gt;
For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=X68000&amp;diff=1841</id>
		<title>X68000</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=X68000&amp;diff=1841"/>
				<updated>2025-11-29T11:43:15Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: /* Video display */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Sharp X68000 ==&lt;br /&gt;
The Sharp X68000 is a home computer created by Sharp Corporation. It was first released in 1987 and sold only in Japan.&lt;br /&gt;
&lt;br /&gt;
The initial model has a 10 MHz Motorola 68000 CPU, 1 MB of RAM, and lacks a hard drive. The final model was released in 1993 with a 25 MHz Motorola 68030 CPU, 4 MB of RAM, and optional 80 MB SCSI hard drive. RAM in these systems is expandable to 12 MB, though most games and applications do not require more than 2 MB.&lt;br /&gt;
&lt;br /&gt;
The X68000 has graphics hardware similar to arcade video games of the late-1980s, with custom coprocessors supporting scrolling, tiled backgrounds, and large numbers of sprites. Sound is supplied through multiple sound chips supporting 8 channels of FM synthesis and one channel of adaptive differential pulse-code modulation audio, which are mixed down to 2 analog stereo channels via a DAC chip. As such, video gaming was a major use of the X68000. &lt;br /&gt;
&lt;br /&gt;
The X68000 runs an operating system called Human68k which was developed for Sharp by Hudson Soft. An MS-DOS-workalike, Human68k features English-based commands very similar to those in MS-DOS;&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Tools: NDC to create an XDF Disk Image containing the production&lt;br /&gt;
* Emulator(s): http://retropc.net/pi/xm6/index.html , https://www.retrostic.com/emulators/sharp-x68000/winx68030, https://mijet.eludevisibility.org/XM6%20Pro-68k/XM6%20Pro-68k.html&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
address 	vector 	Function 	&lt;br /&gt;
$000000 	$00 	SSP after reset 	&lt;br /&gt;
$000004 	$01 	PC after reset 	&lt;br /&gt;
$000008 	$02 	Bus error 	&lt;br /&gt;
$00000c 	$03 	Address error 	&lt;br /&gt;
$000010 	$04 	Unknown instruction 	&lt;br /&gt;
$000014 	$05 	Division by 0 	&lt;br /&gt;
$000018 	$06 	CHK instruction 	&lt;br /&gt;
$00001c 	$07 	TRAPV instruction, FTRAPcc instruction 	&lt;br /&gt;
$000020 	$08 	Privilege violation 	&lt;br /&gt;
$000024 	$09 	Trace exception 	&lt;br /&gt;
$000028 	$0a 	Unsupported instruction line 1010 emulator (SX call) 	&lt;br /&gt;
$00002c 	$0b 	? line 1111 emulator (DOS call, floating point operation) 	&lt;br /&gt;
$000030 	$0c 	Unused 	&lt;br /&gt;
$000034 	$0d 	FPU Protocol violation exception handling 	&lt;br /&gt;
$000038 	$0e   	Formatting error exception handling 	&lt;br /&gt;
$00003c 	$0f 	Uninitialized Interrupt 	&lt;br /&gt;
$000040 	$10 	Unused 	&lt;br /&gt;
$000044 	$11 	? 	&lt;br /&gt;
$000048 	$12 	? 	&lt;br /&gt;
$00004c 	$13 	? 	&lt;br /&gt;
$000050 	$14 	? 	&lt;br /&gt;
$000054 	$15 	? 	&lt;br /&gt;
$000058 	$16 	? 	&lt;br /&gt;
$00005c 	$17 	? 	&lt;br /&gt;
$000060 	$18 	Spurious Interrupt 	&lt;br /&gt;
$000064 	$19 	Level 1 Interrupt (auto vector) 	&lt;br /&gt;
$000068 	$1a 	? 	&lt;br /&gt;
$00006c 	$1b 	? 	&lt;br /&gt;
$000070 	$1c 	? 	&lt;br /&gt;
$000074 	$1d 	? 	&lt;br /&gt;
$000078 	$1e 	? 	&lt;br /&gt;
$00007c 	$1f 	? 	&lt;br /&gt;
$000080 	$20 	trap #0 	&lt;br /&gt;
$000084 	$21 	? #1 	&lt;br /&gt;
$000088 	$22 	? #2 	&lt;br /&gt;
$00008c 	$23 	? #3 	&lt;br /&gt;
$000090 	$24 	? #4 	&lt;br /&gt;
$000094 	$25 	? #5 	&lt;br /&gt;
$000098 	$26 	? #6 	&lt;br /&gt;
$00009c 	$27 	? #7 	&lt;br /&gt;
$0000a0 	$28 	? #8 (reserved for system) 	&lt;br /&gt;
$0000a4 	$29 	? #9 (OS debugger) 	&lt;br /&gt;
$0000a8 	$2a 	? #10 (reset &amp;amp; power off) 	&lt;br /&gt;
$0000ac 	$2b 	? #11 (BREAK key) 	&lt;br /&gt;
$0000b0 	$2c 	? #12 (COPY key) 	&lt;br /&gt;
$0000b4 	$2d 	? #13 (CTRL+C) 	&lt;br /&gt;
$0000b8 	$2e 	? #14 (error processing) 	&lt;br /&gt;
$0000bc 	$2f 	? #15 (IOCS call) 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c0 	$30 	FPU BSUN 	&lt;br /&gt;
$0000c4 	$31 	? INEX1,INEX2 	&lt;br /&gt;
$0000c8 	$32 	? DZ 	&lt;br /&gt;
$0000cc 	$33 	? UNFL 	&lt;br /&gt;
$0000d0 	$34 	? OPERR 	&lt;br /&gt;
$0000d4 	$35 	? OVFL 	&lt;br /&gt;
$0000d8 	$36 	? SNAN 	&lt;br /&gt;
$0000dc 	$37 	??? 	&lt;br /&gt;
$0000dc 	$37 	Unused 	&lt;br /&gt;
$0000e0 	$38 	MMU 	&lt;br /&gt;
$0000e4 	$39 	? 	&lt;br /&gt;
$0000e8 	$3a 	? 	&lt;br /&gt;
$0000ec 	$3b 	Unused 	&lt;br /&gt;
$0000fc 	$3f 	Unused 	&lt;br /&gt;
$000100 	$40 	MFP RTC Alarm/1Hz 	&lt;br /&gt;
$000104 	$41 	MFP External power OFF 	&lt;br /&gt;
$000118 	$42 	MFP Front switch OFF 	&lt;br /&gt;
$00010c 	$43 	MFP FM Audio source 	&lt;br /&gt;
$000110 	$44 	MFP Timer-D (Used with BG processing) 	&lt;br /&gt;
$000114 	$45 	MFP Timer-C (Mouse/cursor/FDD control, etc.) 	&lt;br /&gt;
$000118 	$46 	MFP V-DISP 	&lt;br /&gt;
$00011c 	$47 	MFP RTC Clock 	&lt;br /&gt;
$000120 	$48 	MFP Timer-B 	&lt;br /&gt;
$000124 	$49 	MFP Key serial output error 	&lt;br /&gt;
$000128 	$4a 	MFP Key serial output empty 	&lt;br /&gt;
$00012c 	$4b 	MFP Key serial input error 	&lt;br /&gt;
$000130 	$4c 	MFP Key serial input 	&lt;br /&gt;
$000134 	$4d 	MFP Timer-A 	&lt;br /&gt;
$000138 	$4e 	MFP CRTC*IRQ 	&lt;br /&gt;
$00013c 	$4f 	MFP H-SYNC 	&lt;br /&gt;
$000140 	$50 	SCC(B) Transmission buffer empty 	&lt;br /&gt;
$000144 	$51 	SCC(B) '' 	&lt;br /&gt;
$000148 	$52 	SCC(B) External/status changes 	&lt;br /&gt;
$00014c 	$53 	SCC(B) '' 	&lt;br /&gt;
$000150 	$54 	SCC(B) Incoming character validity (Mouse 1 byte input) 	&lt;br /&gt;
$000154 	$55 	SCC(B) '' 	&lt;br /&gt;
$000158 	$56 	SCC(B) Special Rx condition 	&lt;br /&gt;
$00015c 	$57 	SCC(B) '' 	&lt;br /&gt;
$000160 	$58 	SCC(A) Transmission buffer empty 	&lt;br /&gt;
$000164 	$59 	SCC(A) '' 	&lt;br /&gt;
$000168 	$5a 	SCC(A) External status changes 	&lt;br /&gt;
$00016c 	$5b 	SCC(A) '' 	&lt;br /&gt;
$000170 	$5c 	SCC(A) Incoming character validity (RS-232C 1 byte input) 	&lt;br /&gt;
$000174 	$5d 	SCC(A) '' 	&lt;br /&gt;
$000178 	$5e 	SCC(A) Special Rx Condition 	&lt;br /&gt;
$00017c 	$5f 	SCC(A) '' 	&lt;br /&gt;
$000180 	$60 	I/O FDC status interruption 	&lt;br /&gt;
$000184 	$61 	I/O FDC insertion/discharge interruption 	&lt;br /&gt;
$000188 	$62 	I/O HDC status interruption 	&lt;br /&gt;
$00018c 	$63 	I/O Printer ready interruption 	&lt;br /&gt;
$000190 	$64 	DMAC #0 End (FDD) 	&lt;br /&gt;
$000194 	$65 	DMAC #0 Error ('') 	&lt;br /&gt;
$000198 	$66 	DMAC #1 End (SASI) 	&lt;br /&gt;
$00019c 	$67 	DMAC #1 Error ('') 	&lt;br /&gt;
$0001a0 	$68 	DMAC #2 End (IOCS _DMAMOVE,_DMAMOV_A,_DMAMOV_L) 	&lt;br /&gt;
$0001a4 	$69 	DMAC #2 Error ('') 	&lt;br /&gt;
$0001a8 	$6a 	DMAC #3 End (ADPCM) 	&lt;br /&gt;
$0001ac 	$6b 	DMAC #3 Error ('') 	&lt;br /&gt;
$000200 	$6c 	SPC SCSI interruption (Internal SCSI) 	&lt;br /&gt;
$000204 	$6d 	Unused 	&lt;br /&gt;
$0003d4 	$f5 	Unused 	&lt;br /&gt;
$0003d8 	$f6 	SPC SCSI interruption (SCSI board) 	&lt;br /&gt;
$0003dc 	$f7 	Unused 	&lt;br /&gt;
$0003fc 	$ff 	Unused 	&lt;br /&gt;
0x000000 	RAM area 	&lt;br /&gt;
$c00000 	Graphics Vram � Page 0 	&lt;br /&gt;
$c80000 	Graphics Vram � Page 1 (256/16 color only) 	&lt;br /&gt;
$d00000 	Graphics Vram � Page 2 (16 color only)&lt;br /&gt;
$d80000 	Graphics Vram � Page 3 (16 color only) 	&lt;br /&gt;
$e00000 	Text Vram � Bitplane 0 	&lt;br /&gt;
$e20000 	Text Vram � Bitplane 1&lt;br /&gt;
$e40000 	Text Vram � Bitplane 2&lt;br /&gt;
$e60000 	Text Vram � Bitplane 3&lt;br /&gt;
$e80000 	1.w 	R00 Horizontal total 	&lt;br /&gt;
$e80002 	1.w 	R01 Horizontal synchronization end position timing 	&lt;br /&gt;
$e80004 	1.w 	R02 Horizontal display start position 	&lt;br /&gt;
$e80006 	1.w 	R03 Horizontal display end position 	&lt;br /&gt;
$e80008 	1.w 	R04 Vertical total 	&lt;br /&gt;
$e8000a 	1.w 	R05 Vertical synchronization end position timing 	&lt;br /&gt;
$e8000c 	1.w 	R06 Vertical display start position 	&lt;br /&gt;
$e8000e 	1.w 	R07 Vertical display end position 	&lt;br /&gt;
$e80010 	1.w 	R08 External synchronization horizontal adjust: Horizontal position tuning 	&lt;br /&gt;
$e80012 	1.w 	R09 Raster number: Used for raster interruption 	&lt;br /&gt;
$e80014 	1.w 	R10 Text Screen X coordinate 	&lt;br /&gt;
$e80016 	1.w 	R11 Text Screen Y coordinate 	&lt;br /&gt;
$e80018 	1.w 	R12 Graphics screen Scroll X0 	&lt;br /&gt;
$e8001a 	1.w 	R13 Graphics screen Scroll Y0 	&lt;br /&gt;
$e8001c 	1.w 	R14 Graphics screen Scroll X1 	&lt;br /&gt;
$e8001e 	1.w 	R15 Graphics screen Scroll Y1 	&lt;br /&gt;
$e80020 	1.w 	R16 Graphics screen Scroll X2 	&lt;br /&gt;
$e80022 	1.w 	R17 Graphics screen Scroll Y2 	&lt;br /&gt;
$e80024 	1.w 	R18 Graphics screen Scroll X3 	&lt;br /&gt;
$e80026 	1.w 	R19 Graphics screen Scroll Y3 	&lt;br /&gt;
$e80028 	1.w 	R20 Memory mode/Display mode control 	&lt;br /&gt;
$e8002a 	1.w 	R21 Simultaneous access/Raster copy/Quick clear plane select 	&lt;br /&gt;
$e8002c 	1.w 	R22 Raster copy action: Raster number 	&lt;br /&gt;
$e8002e 	1.w 	R23 Text screen access mask pattern 	&lt;br /&gt;
$e80481 	1.b 	Active Image capture/Quick clear/Raster copy control 	&lt;br /&gt;
$e82000 	256.w 	Graphics palette 	&lt;br /&gt;
$e82200 	16.w 	Text palette (Palette block 0) 	&lt;br /&gt;
$e82220 	240.w 	Sprite palette ('' 1-15) 	&lt;br /&gt;
$e82400 	1.w 	R0 (Screen mode initialization) 	&lt;br /&gt;
$e82500 	1.w 	R1 (Priority control) 	&lt;br /&gt;
$e82600 	1.w 	R2 (Special priority/screen display) - Layers On/Off&lt;br /&gt;
$e84000 	DMAC (HD63450) 	&lt;br /&gt;
$e86000 	Memory controller privileged access settings (OHM/ASA) 	&lt;br /&gt;
$e88000 	MFP (MC68901) 	&lt;br /&gt;
$e8a000 	RTC (RP5C15) 	&lt;br /&gt;
$e8c000 	Printer port 	&lt;br /&gt;
$e8e001 	#1 Contrast 	&lt;br /&gt;
$e8e003 	#2 Display/3D Shutter Glasses (Bit 0=Right Eye / Bit 1 = Left Eye)&lt;br /&gt;
$e8e005 	#3 Color image unit (bit 4-0) 	&lt;br /&gt;
$e8e007 	#4 Keyboard/NMI/dot clock 	&lt;br /&gt;
$e8e009 	#5 ROM/DRAM Wait 	&lt;br /&gt;
$e8e00b 	#6 MPU Classification/Operation clock 	&lt;br /&gt;
$e8e00d 	#7 SRAM Write 	&lt;br /&gt;
$e8e00f 	#8 Unit power OFF 	&lt;br /&gt;
$E90001 	FM Synthesizer (YM2151) - Register Address Write port 	&lt;br /&gt;
$E90003 	FM Synthesizer (YM2151) - Data R/W port 	&lt;br /&gt;
$E92000 	ADPCM (MSM6258V) 	&lt;br /&gt;
$E94000 	Floppy disk controller (FDC) (uPD72065) 	&lt;br /&gt;
$E94005 	Floppy drive monitor (IOSC) 	&lt;br /&gt;
$E96000 	SASI 	&lt;br /&gt;
$E98000 	ESCC (Z8530) 	&lt;br /&gt;
$E9A000 	PPI (82C55) 	&lt;br /&gt;
$E9C000 	I/O selector (IOSC) 	&lt;br /&gt;
$E9E000 	I/O expansion area (Sharp reserved) 	&lt;br /&gt;
$EB0000 	Sprite register (CYNTHIA) 	&lt;br /&gt;
$EB8000 	Sprite VRAM 	&lt;br /&gt;
$EC0000 	I/O expansion area (User) 	&lt;br /&gt;
$ed0072 	2.b 	SX-Window environment flag (While in use with &amp;quot;SX&amp;quot;) 	&lt;br /&gt;
$ed0074 	1.b 	Standard double-click time / 10 	&lt;br /&gt;
$ed0075 	1.b 	Mouse speed / 2 	&lt;br /&gt;
$ed0076 	1.b 	Text palette hue (HSV) 	&lt;br /&gt;
$ed0077 	1.b 	&lt;br /&gt;
$ed0078 	1.b 	Brightness palette 0-3 5bit??? 	&lt;br /&gt;
$ed007b 	1.b 	Printer drive (PRTD) ID 	&lt;br /&gt;
$ed007c 	1.b 	SRAM info version#, screen status storage, start screen storage 	&lt;br /&gt;
$ed007d 	1.b 	Desktop background (PICT) ID 	&lt;br /&gt;
$ed007e 	1.b 	Screen mode 	&lt;br /&gt;
$ed007f 	17.b 	Reserved for system use (X68030) 	&lt;br /&gt;
$ed0090 	1.b 	Standard cache status (bit=0: off 1:on) 	&lt;br /&gt;
$ed0091 	1.b 	OPM music during startup (0: OFF -1: ON) 	&lt;br /&gt;
$ed0092 	1.b 	10MHz Proper wait value 	&lt;br /&gt;
$ed0093 	1.b 	16MHz '' 	&lt;br /&gt;
$ed0094 	108.b 	Reserved for system use 	&lt;br /&gt;
$ed0100 	768.b 	Head SRAM program address 	&lt;br /&gt;
$ed0400 	15KB 	Head SRAMDISK address 	&lt;br /&gt;
$ed3fff 	End of SRAM 	&lt;br /&gt;
$ed4000 	Backup (64KB) 	&lt;br /&gt;
$ee0000 	Unused (128KB) 	&lt;br /&gt;
$f00000 	CGROM(768KB) 	&lt;br /&gt;
$fc0000 	SCSI IOCS / IPL(8KB) 	&lt;br /&gt;
$fe0000 	ROM Debugger 	&lt;br /&gt;
$ff0000 	IPL / ROM IOCS&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
Here is a list of graphics modes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
d1.w =	 0	1024	 512 x 512	16	1	31&lt;br /&gt;
	1	V		V	V	V	15&lt;br /&gt;
	2	V	 256 x 256	V	V	31&lt;br /&gt;
	3	V		V	V	V	15&lt;br /&gt;
	4	512	 512 x 512	16	4	31&lt;br /&gt;
	5	V		V	V	V	15&lt;br /&gt;
	6	V	 256 x 256	V	V	31&lt;br /&gt;
	7	V		V	V	V	15&lt;br /&gt;
	8	V	 512 x 512	256	2	31&lt;br /&gt;
			 9	V		V	V	V	15&lt;br /&gt;
			10	V	 256 x 256	V	V	31&lt;br /&gt;
			11	V		V	V	V	15&lt;br /&gt;
			12	V	 512 x 512	65536	1	31&lt;br /&gt;
			13	V		V	V	V	15&lt;br /&gt;
			14	V	 256 x 256	V	V	31&lt;br /&gt;
			15	V		V	V	V	15&lt;br /&gt;
			16	1024	 768 x 512	16	1	31&lt;br /&gt;
			17	V	1024 x 424	V	V	24&lt;br /&gt;
			18	V	1024 x 848	V	V	24&lt;br /&gt;
&lt;br /&gt;
			19	V	 640 x 480	V	V	24&lt;br /&gt;
&lt;br /&gt;
			20	V	 768 x 512	256	2	31&lt;br /&gt;
			21	V	1024 x 848	V	V	24&lt;br /&gt;
			22	V	1024 x 424	V	V	24&lt;br /&gt;
			23	V	 640 x 480	V	V	24&lt;br /&gt;
			24	V	 768 x 512	65536	1	31&lt;br /&gt;
			25	V	1024 x 848	V	V	24&lt;br /&gt;
			26	V	1024 x 424	V	V	24&lt;br /&gt;
			27	V	 640 x 480	V	V	24&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
waitVBlank:&lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for vblank to start&lt;br /&gt;
    beq waitVBlank&lt;br /&gt;
waitVBlank2:   &lt;br /&gt;
    move.w $e88000,d0&lt;br /&gt;
    and.w #%00010000,d0            ;Wait for Vblank to end&lt;br /&gt;
    bne waitVBlank2&lt;br /&gt;
    rts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
To be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
&lt;br /&gt;
The X68000 has a YM2151 FM Soundchip on board with 8 channels.&lt;br /&gt;
Each channel's sound can be built up with 4 different 'slots'... meaning there are a total of 32 slots... these slots are turned on or off when the sound is triggered&lt;br /&gt;
&lt;br /&gt;
For more information, check out the YM2151 specs at [https://msxpro.com/datasheet.html]&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://www.chibiakumas.com/68000/x68000.php Assembly programming for the X68000]&lt;br /&gt;
* [https://archive.org/details/X68000_488] X68000 Technical data book&lt;br /&gt;
* [https://msxpro.com/datasheet.html] YM2151 Datasheet&lt;br /&gt;
* [https://demozoo.org/productions/?platform=100 X68000 demoscene productions]&lt;br /&gt;
* [https://archive.org/details/cpsystem/page/202/mode/2up X68000 chapter in the book &amp;quot;The Book of CP-System&amp;quot;]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1840</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1840"/>
				<updated>2025-11-28T12:05:06Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x pixel shift&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
 lsl.b   #6,d2&lt;br /&gt;
 bcc     .noGreen&lt;br /&gt;
 add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
 lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
 or.w    d2,(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1839</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1839"/>
				<updated>2025-11-28T11:55:42Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
                lsl.w   #6,d1           ; y byte&lt;br /&gt;
                moveq   #3,d3           ; x pixel shift&lt;br /&gt;
                and.w   d0,d3&lt;br /&gt;
                add.w   d3,d3&lt;br /&gt;
                asr.w   #2,d0           ; x byte&lt;br /&gt;
                add.w   d0,d1           ; total bytes&lt;br /&gt;
                add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
                lsl.b   #6,d2&lt;br /&gt;
                bcc     .noGreen&lt;br /&gt;
                add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
                lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
                or.w    d2,(a0,d1)&lt;br /&gt;
                rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1838</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1838"/>
				<updated>2025-11-28T11:55:30Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
===== Plot blue =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; plot pixel&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y, d2 = color index 0-7&lt;br /&gt;
plot:&lt;br /&gt;
                lsl.w   #6,d1           ; y byte&lt;br /&gt;
                moveq   #3,d3           ; x pixel shift&lt;br /&gt;
                and.w   d0,d3&lt;br /&gt;
                add.w   d3,d3&lt;br /&gt;
                asr.w   #2,d0           ; x byte&lt;br /&gt;
                add.w   d0,d1           ; total bytes&lt;br /&gt;
                add.w   d1,d1           ; to word offset&lt;br /&gt;
&lt;br /&gt;
                lsl.b   #6,d2&lt;br /&gt;
                bcc     .noGreen&lt;br /&gt;
                add.w   #$8000,d2&lt;br /&gt;
.noGreen:&lt;br /&gt;
                lsr.w   d3,d2           ; shift scrambled color to px pos&lt;br /&gt;
                or.w    d2,(a0,d1)&lt;br /&gt;
                rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1837</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1837"/>
				<updated>2025-11-28T11:52:06Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
===== Plot blue =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; draw a blue dot&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y&lt;br /&gt;
plot_blue:&lt;br /&gt;
 lsl.w   #6,d1           ; y byte&lt;br /&gt;
 moveq   #3,d3           ; x bit&lt;br /&gt;
 and.w   d0,d3&lt;br /&gt;
 not.w   d3&lt;br /&gt;
 add.w   d3,d3&lt;br /&gt;
 asr.w   #2,d0           ; x byte&lt;br /&gt;
 add.w   d0,d1           ; total bytes&lt;br /&gt;
 add.w   d1,d1           ; to word offset&lt;br /&gt;
 bset.b  d3,1(a0,d1)&lt;br /&gt;
 rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1836</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1836"/>
				<updated>2025-11-28T11:51:29Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
While there are a few rom/trap routines that allow you to draw primitives, these are quite expensive to setup and clunky to use.&lt;br /&gt;
So its best to draw into the screenmemory directly, using the following plot routines provided by gigabates.&lt;br /&gt;
&lt;br /&gt;
===== Plot blue =====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
; draw a blue dot&lt;br /&gt;
; a0 = screen,  d0 = x, d1 = y&lt;br /&gt;
plot_blue:&lt;br /&gt;
	lsl.w   #6,d1           ; y byte&lt;br /&gt;
	moveq   #3,d3           ; x bit&lt;br /&gt;
	and.w   d0,d3&lt;br /&gt;
	not.w   d3&lt;br /&gt;
	add.w   d3,d3&lt;br /&gt;
	asr.w   #2,d0           ; x byte&lt;br /&gt;
	add.w   d0,d1           ; total bytes&lt;br /&gt;
	add.w   d1,d1           ; to word offset&lt;br /&gt;
	bset.b  d3,1(a0,d1)&lt;br /&gt;
	rts &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1835</id>
		<title>Spectrum QL</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=Spectrum_QL&amp;diff=1835"/>
				<updated>2025-11-28T11:48:36Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: /* Spectrum QL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Spectrum QL ==&lt;br /&gt;
The Sinclair QL (for Quantum Leap) is a personal computer launched by Sinclair Research in 1984, as an upper-end counterpart to the ZX Spectrum.&lt;br /&gt;
It was aimed at the serious home user and professional and executive users markets from small to medium-sized businesses and higher educational establishments, but failed to achieve commercial success.&lt;br /&gt;
The Sinclair QL uses a Motorola 68008.CPU with 32-bit internal data registers, but an 8-bit external data bus.&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
* Assembler: VASM&lt;br /&gt;
* Emulator(s): Q-emulator ( http://www.terdina.net/ql/winql.html )&lt;br /&gt;
* Tool(s): mdvtool (create MDV images)&lt;br /&gt;
* Hardware:&lt;br /&gt;
In order to test the final result one can use a floppy-disk replace replacement or Qubide interface to load files from SD card.&lt;br /&gt;
&lt;br /&gt;
=== Loader ===&lt;br /&gt;
To load content from a folder or MDV image, you need both the binary and a basic loader, similar to platforms like the ZX Spectrum and CPC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
10 PROGRAM=RESPR(512)&lt;br /&gt;
15 LBYTES &amp;quot;MYINTRO.BIN&amp;quot;,PROGRAM&lt;br /&gt;
20 CALL PROGRAM&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can link the folder directly from the Q-emulator or generate a MDV image using mdvtool for distribution.&lt;br /&gt;
&lt;br /&gt;
=== Memory map ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
$00000 	Onboard 48k Rom 	&lt;br /&gt;
$0C000 	16K Rom Cartridge 	&lt;br /&gt;
$10000 	Onboard I/O 	&lt;br /&gt;
$18000 	(R) RTC byte 0 / (W) RTC Reset&lt;br /&gt;
$18001 	(R) RTC byte 1 / (W) RTC Step&lt;br /&gt;
$18002 	(R) RTC byte 2 / (W) Transmit control&lt;br /&gt;
$18003 	(R) RTC byte 3 / (W) IPC link control&lt;br /&gt;
$18020 	(R) Microdrive/RS232c status / (W) Microdrive control&lt;br /&gt;
$18021 	(R) Interrupt/IPC status / (W) Interrupt control&lt;br /&gt;
$18022 	(R) Microdrive Track 1 / (W) Microdrive / RS232C data&lt;br /&gt;
$18023 	(R) Microdrive Track 2 / (W) Display control&lt;br /&gt;
$18063 	Screen Mode S---C-O- On Colordepth Screenpage&lt;br /&gt;
$20000 	Screen 1 	Screen Ram&lt;br /&gt;
$28000 	Screen 2 /&lt;br /&gt;
System 	system (systemvars*)&lt;br /&gt;
$2847C 	System stack pointer*&lt;br /&gt;
$28E00 	Base of Common Heap*&lt;br /&gt;
$2BC00 	Free area*&lt;br /&gt;
$30000 	Running Programs 	Free area&lt;br /&gt;
$37200 	Basic area*&lt;br /&gt;
$38000 	User Stack pointer*&lt;br /&gt;
$38000 	Prog data*&lt;br /&gt;
$40000 	Add on ram (up to 512k) 	&lt;br /&gt;
$C0000 	Add on peripherals 	&lt;br /&gt;
$E0000 	Add on Rom (up to 128k) 	&lt;br /&gt;
$FFFFF 	End of address space&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video display ===&lt;br /&gt;
There are two possible screen modes, configured by bit 3 of port $18063&lt;br /&gt;
&lt;br /&gt;
setting a 0 give 4 colors at 512x256 with Black,Red,Green and White&lt;br /&gt;
setting a 1 give 8 colors at 256x256 with Black,  R, G B, C, M, Y and White&lt;br /&gt;
&lt;br /&gt;
The Screen is directly memory mapped from $20000-$28000, There is no palette - the colors are fixed.&lt;br /&gt;
&lt;br /&gt;
==== Vsync ====&lt;br /&gt;
Port $18021 bit 3 will go high (1) when Vsync starts, then we need to write a 1 to that same bit at the same port to clear the Vsync event.&lt;br /&gt;
Therefore, in effect we can write 255 to port $18021, then read from $18021 until it's nonzero to get the Vsync event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  move.b #%11111111, $18021     ; Clear interrupt bits&lt;br /&gt;
waitvbl:&lt;br /&gt;
    move.b $18021,d0            ; Read in interrupt state&lt;br /&gt;
    tst.b d0                    ; Wait for an interrupt&lt;br /&gt;
    beq waitvbl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Plotting to screen ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
To be added&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sound ===&lt;br /&gt;
The Spectrum QL has 2 channels of internal beeped sound, or AY support via an extension board.&lt;br /&gt;
&lt;br /&gt;
Speaker Sound commands have to be passed via the Bios, using the same kind of commands as with the keyboard.&lt;br /&gt;
You need to adjust the Pitch settings to change the sound, and you can change the randomness bits to make the sound distorted, It seems it's not possible to change the volume!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
move.l #$11,d0			; set sound command&lt;br /&gt;
lea .sounddata,a3		; load sound message payload pointer to a3&lt;br /&gt;
trap #1				; call dosound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional Resources ===&lt;br /&gt;
* [https://ia600804.us.archive.org/9/items/SinclairQLHomepage/docs/manuals/qltm.pdf QL Technical Guide]&lt;br /&gt;
* [https://www.chibiakumas.com/68000/sinclairql.php 68008 Assembly programming for the Sinclair QL]&lt;br /&gt;
* [https://dilwyn.qlforum.co.uk/  Sinclair QL Pages]&lt;br /&gt;
* [http://www.terdina.net/ql/winql.html Q_emulator]&lt;br /&gt;
* [https://demozoo.org/productions/?platform=95 Sinclair QL demoscene productions]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1833</id>
		<title>4K Intro</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1833"/>
				<updated>2025-11-04T00:02:26Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
This category is dedicated to modern 4K Intro development for [[Windows|Windows / Win32]], which consist of a small OpenGL/D3D/DX Framework, a softsynth and 1 or more pixelshaders. As such this won't be discussion legacy mesh techniques as few 4k intros make use of those techniques anymore.&lt;br /&gt;
&lt;br /&gt;
Most Windows 4K Intros will be setup using C, sometimes in combination with assembler, or in some cases pure assembler. In general writing everything in assembler should give you a little more freedom in pushing/popping your function arguments and register usage.&lt;br /&gt;
&lt;br /&gt;
Graphics are usualy done using OpenGL / GLSL or Direct3D/DX11.&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
There are a couple of options for tools, but generally these tools are often used&lt;br /&gt;
* Visual Studio / Vscode / GCC Compiler &lt;br /&gt;
* Crinkler or other external packer for compression ( https://crinkler.net )&lt;br /&gt;
* Shader minifier ( https://github.com/laurentlb/Shader_Minifier )&lt;br /&gt;
* Optional / Alternatively: NASM Assembler ( https://nasm.us/ )&lt;br /&gt;
* Optional: Local/Online GLSL Shader editing environment (e.g. Shadertoy, Kodelife, bonzo, etc.)&lt;br /&gt;
* Optional: Timeline/Camera tooling&lt;br /&gt;
* Optional: gnuRocket for timing.&lt;br /&gt;
&lt;br /&gt;
== Intro design ==&lt;br /&gt;
When designing a 4k intro, it is best practice to consider each of the following aspects seperately:&lt;br /&gt;
&lt;br /&gt;
* How much size budget do you want to allocate to render pipeline, sound, scene building, (post)shading, progression?&lt;br /&gt;
* Abstract vs organic vs scene/world-building &lt;br /&gt;
* Single scene vs multiple scenes&lt;br /&gt;
* Ray-Intersections or Ray Marching&lt;br /&gt;
* What kind of softsynth to use, or writing your own&lt;br /&gt;
* Render pipeline - Single or multipass (post/audio)shaders.&lt;br /&gt;
* Scene, Camera and progression handling&lt;br /&gt;
* Text - Do you want to include text and if so: Are you using WindowsGlyphs texture or SDF&lt;br /&gt;
&lt;br /&gt;
=== Design pitfalls ===&lt;br /&gt;
Here are a few design pitfalls you should try to avoid if necessary.&lt;br /&gt;
&lt;br /&gt;
==== Undirected raymarch experiments ====&lt;br /&gt;
Wiggly domain repetition shadertoy experiments, with or without walking glows, might be sufficient for a shaderjam or shader-showdown, but usually make a sub-par 4k intro. Don't do it, even if it has the compofiller banner on the slide.&lt;br /&gt;
  &lt;br /&gt;
====  The Rebranded cornell box - Just a shiny sphere bro! ==== &lt;br /&gt;
Its great as a rendertest reference for your PBR / pathtracing tests, but it doesn't make a compelling intro.&lt;br /&gt;
The times you still see a reflective/pathtraced sphere and/or box with music mask as a 4k intro is staggering. &lt;br /&gt;
Sadly sceners still accept these rebranded cornell boxes as legit and even winning/cdc receiving intros, because shineys.&lt;br /&gt;
But my intuition says these will be looked upon like the countless early 2000s goa+bended sphers/torus intros that fail to stand the test of time.&lt;br /&gt;
&lt;br /&gt;
====  Shitty synths ==== &lt;br /&gt;
There are a few great intros out there that have great visuals but are ruined by glopawful synths or music. If you are not good at music yourself, find yourself a musician to work with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Size Budgeting ==&lt;br /&gt;
A general rule of thumb is to work above the target size for most of the development and work your way down when the production is closer to completion.&lt;br /&gt;
&lt;br /&gt;
There are many ways to split the same bytes, here are the top-5 4K Intros at Revision 2024 that have made wildly different choices.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Ranking !! Intro Title !! Progression / Storytelling !! Object complexity || Graphics Fidelity !! Sound !! Notes !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Drifting Shore || Low || Low || Very-High || Low || Ray-Intersection + Pathtracing || https://demozoo.org/productions/342196/&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Dubplate || Medium || Low || High || Very-High || SDF Text || https://demozoo.org/productions/342202/&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Return to nature || High || High || Low || Low || - || https://demozoo.org/productions/342200/&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Brainfiller || Low || Medium || High || High || GLSL Softsynth || https://demozoo.org/productions/342203/&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Once Upon A Time In A Datacenter || High || Very-High || Low || Low || Custom CPU synthcode || https://demozoo.org/productions/342199/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Graphics fidelity ====&lt;br /&gt;
TBA&lt;br /&gt;
&lt;br /&gt;
==== Music budget ====&lt;br /&gt;
Got a musician to work with you and deliver a great tune? Don't accept it right out of the gate and feel free to argue about possible optimisations that can be done to the tune that will not affect the end-result massively. This is done by all of the better-known 4k intro developers and a good musician will be open to discussion and aware of the different limitation and choices that have to be made when it comes to size budgeting.&lt;br /&gt;
&lt;br /&gt;
== Setting up your framework ==&lt;br /&gt;
A 4k framework / intro can be setup in either C or Assembler, or a combination of both.&lt;br /&gt;
You can either go with an existing framework (some of them are quite capable) or build your own taylored to your own needs.&lt;br /&gt;
Also remember that even though there are many more ways to save size than in for example a 1k intro, that every byte saved here is one you can spent / budget elsewhere.&lt;br /&gt;
&lt;br /&gt;
* The groundlevel basics of a framework are discussed on the 1K Intro wiki at http://www.sizecoding.org/wiki/1K_Intro&lt;br /&gt;
* From here you can setup your audiobuffer add a softsynth of choice, or write your own (either in GLSL or Software)&lt;br /&gt;
* Most likely you'll like to add a few more function imports to properly pass uniforms to your shader.&lt;br /&gt;
* Optionally: Add another render-pass by feeding the output of the main shader to a post-shading process. This adds a few more texture calls to the framework&lt;br /&gt;
* Optionally: Add an init pass where you prepare (glyph) textures and other buffers you'd like to feed into your main shader.&lt;br /&gt;
* Optionally: Hook up a Scene/Camera/Timing system during development&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
Once you've budgeted and designed your intro, it is time to go to work. &lt;br /&gt;
&lt;br /&gt;
==== Prebuild your scene in an external tool ====&lt;br /&gt;
For convenience and turn-around time, its perfectly fine to use external online/offline tools like Shadertoy, Posh-Brolly, Kodelife, Bonzo or others to setup you main scene(s) / effects.&lt;br /&gt;
&lt;br /&gt;
==== Ray-Intersetions vs Raymarching ====&lt;br /&gt;
In theory ideally you'd like to have multi-sample, multiple bounces, highly flexible, highly accurate raymarching&lt;br /&gt;
But in practice this is as of year (2024) still impossible to do realtime on most systems, therefore a choice has to be made between exact interesctions of primitives / raytracing vs ray marching. What are the differences in usecases and what are their pros and cons:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Raymarching !! Ray-Intersection !! Examples&lt;br /&gt;
|-&lt;br /&gt;
| Domain-Repetition || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Fast Multi-Sample || No || Yes || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Twisting &amp;amp; Blending || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Shape-Blending || Yes || ? || TBA&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Post processing: Don't miss the low-hanging fruit ====&lt;br /&gt;
Having a proper post processing step can greatly improve the overall visual quality of your intro. So in 4k space i would suggest a postshader pass at minimum, which depending on your size budget you can use for things like Vignetting, DOF, tone-mapping, anti-aliasing, chromatic abberation, etc. &lt;br /&gt;
&lt;br /&gt;
But even if your 4k intro doesn't have a seperate post-shader pass, adding a bit of in-shader vignetting / gamma correction / tone-mapping to your intro are relative easy/cheap ways to improve visual quality of your intro, so why leave those options off the table?&lt;br /&gt;
For inspiration, You can check out the article at Here is an article at https://30fps.net/pages/post-processing/ for a few things you can do to improve your visuals in post.&lt;br /&gt;
&lt;br /&gt;
== Sound ==&lt;br /&gt;
Here is an overview of various Synths / Music options.&lt;br /&gt;
Depending on the exact track, you are looking at approx 1k - 1.5k compressed for music for most 4k intros.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Synth !! Type !! Description !! Size overhead !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 4klang || Subtractive || Most popular softsynth || Medium (1 note, 1 instrument at 620b) || https://github.com/gopher-atz/4klang&lt;br /&gt;
|-&lt;br /&gt;
| Sointu || Subtractive || 4klang fork with improvements || Medium (1 note, 1 instrument at 562b )|| https://github.com/vsariola/sointu/&lt;br /&gt;
|-&lt;br /&gt;
| Oidos || Additive || - || Medium (1 note, 1 instrument at 600b) || https://github.com/askeksa/Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Clinkster || FM || - || Medium (1 note, 1 instrument at 590b) || http://crinkler.net/Clinkster.zip&lt;br /&gt;
|-&lt;br /&gt;
| GLSL Softsynth || - || Write it yourself || Small/Medium (depends on usecase) || -&lt;br /&gt;
|-&lt;br /&gt;
| MIDI Player || MIDI || Using default Windows midi sounds || Small/Medium (depends on player/song complexity) || -&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As a snapshot. Here is a list of intros from 2017 with the synth they used:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Absolute Territory || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Waillee || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| final stage || Custom&lt;br /&gt;
|-&lt;br /&gt;
| Horizon Machine || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Unprogress || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Faraday Future || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Alive Here Now, Forever || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Destination Unknown || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| w a y f a r e r || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| HAL 4000 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Equilibrium || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| visit berlin || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| お花見 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Gary Glitter || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Superfine || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Cycle Of Nature || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Oxano || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Those Who Leave || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Maintenance || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Joia || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Back to the Roots || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Dropletia || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| crystalline lord || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| highrider || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Primordial Soup || Custom&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
Crinkler is the most commonly used compression at the moment for 4K intros. It maximizes compression by taking over the linking process, setting up the windows header for you and if needed re-arrange the different segments of the code.&lt;br /&gt;
&lt;br /&gt;
==== Crinkler reports ====&lt;br /&gt;
When using the &amp;lt;code&amp;gt;/REPORT:intro_report.html&amp;lt;/code&amp;gt; feature, crinkler will generate a report and heatmap for your intro binary.&lt;br /&gt;
This is helpful to see how well your (shader)code compresses and where you can maybe gain a few more bytes.&lt;br /&gt;
&lt;br /&gt;
==== Word about the resulting executable ====&lt;br /&gt;
Please note that when using crinkler in TINYHEADER mode, the resulting windows header will most likely trigger virus scanners / Microsoft Defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice  to include a (slightly larger) safe version too in the final archive.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
==== Frameworks ====&lt;br /&gt;
* [https://github.com/armak/Leviathan-2.0 Leviathan 2.0]&lt;br /&gt;
* [https://github.com/in4k/isystem1k4k IQ's 1k/4k frameworks]&lt;br /&gt;
* [https://github.com/psycholns/TinyDX11 Psycho's 1k/4k framework]&lt;br /&gt;
* [http://www.kameli.net/compofillerstudio/ Compofiller studio]&lt;br /&gt;
* [https://github.com/yosshin4004/minimal_gl Minimal gl framework]&lt;br /&gt;
* [https://github.com/Beluki/4kGL 4KGL framework]&lt;br /&gt;
* [https://github.com/w23/bepct4k Bepct4k]&lt;br /&gt;
&lt;br /&gt;
==== Raymarching ====&lt;br /&gt;
* [https://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions/ Introduction to Raymarching]&lt;br /&gt;
* [https://iquilezles.org/articles/distfunctions/ IQ's distance functions page]&lt;br /&gt;
* [https://mercury.sexy/hg_sdf/ Mercury's SDF toolbox]&lt;br /&gt;
&lt;br /&gt;
==== High Quality 4K intros for Windows ====&lt;br /&gt;
* [https://demozoo.org/productions/371094/ Hexer (2025)]&lt;br /&gt;
* [https://demozoo.org/productions/355449/ XO (2024)]&lt;br /&gt;
* [https://demozoo.org/productions/331908/ Architectural Shapeshifter (2023)]&lt;br /&gt;
* [https://demozoo.org/productions/311778/ Stahlbeton (2022)]&lt;br /&gt;
* [https://demozoo.org/productions/278629/ The Vanishing of Ashlar (2020)]&lt;br /&gt;
* [https://demozoo.org/productions/266556/ Eisenerz (2019)]&lt;br /&gt;
* [https://demozoo.org/productions/185233/ Oscar's Chair (2018)]&lt;br /&gt;
* [https://demozoo.org/productions/174689/ Unprogress (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/178895/ Waillee (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/170744/ Horizon Machine (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/91680/ Neuron (2013)]&lt;br /&gt;
* [https://demozoo.org/productions/102/ Elevated (2009)]&lt;br /&gt;
* [https://demozoo.org/productions/4846/ Atrium (2008)]&lt;br /&gt;
&lt;br /&gt;
==== 4K intros for Windows with Sourcecode ====&lt;br /&gt;
* [https://github.com/friol/planetx Planet X (2025)]&lt;br /&gt;
* [https://github.com/vsariola/dipping-deep-dub-drop/tree/master Dipping deep dub drop (2025)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2024-08_4k-intro_olkiluoto_3-2-1 Olkiluoto 3-1-1 (2024)]&lt;br /&gt;
* [https://github.com/0b5vr/brainfiller Brainfiller (2024)]&lt;br /&gt;
* [https://github.com/TheNuSan/Lev4k/tree/DriftingShore Drifting Shore (2024)]&lt;br /&gt;
* [https://github.com/vsariola/every-datapoint Every Datapoint has a soul (2024)]&lt;br /&gt;
* [https://github.com/Krafpy/Island/tree/master/ Island (2024)] &lt;br /&gt;
* [https://github.com/LeStahL/ontrack-4k physics girl (2023)]&lt;br /&gt;
* [https://github.com/vsariola/fluxerator Fluxerator (2023)]&lt;br /&gt;
* [https://github.com/vsariola/adam Adam (2021)]&lt;br /&gt;
* [https://github.com/LeStahL/abstraction-confusion Abstraction Confusion (2021)]&lt;br /&gt;
* [https://github.com/w23/jetlag_stuck Stuck (2020)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2019-08_4k-intro_region_de_magallanes Region de Magallanes (2019)]&lt;br /&gt;
* [https://github.com/demoscene-source-archive/oscar-s-chair Oscar's Chair (2018)]&lt;br /&gt;
* [https://github.com/w23/jetlag_appear Appear (2018)]&lt;br /&gt;
* [https://github.com/w23/jetlag_posle Posle (2018)]&lt;br /&gt;
* [https://github.com/w23/nwep nwep (2017)]&lt;br /&gt;
* [https://github.com/keensky/hal4000 Hall4000 (2017)]&lt;br /&gt;
* [https://github.com/in4k/rgba_tbc_elevated_source Elevated (2009)]&lt;br /&gt;
&lt;br /&gt;
==== Seminars ====&lt;br /&gt;
* [https://www.youtube.com/watch?v=S-VDVgCBy-M Shader minification for 4k - 64k intros (2023)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=xLhT06lwaig 4klang 101 - Basics (2019)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=Ir0vcmHkIm0 nstalling and trying out different synths for 4kb intros (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=9BqKH0XNN-g Size Restricted music isn't Rocketscience (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=wP__g_9FT4M Sound Design with 4klang, by Wayfinder (2015)]&lt;br /&gt;
&lt;br /&gt;
==== Articles ====&lt;br /&gt;
* [ftp://ftp.untergrund.net/users/thygrion/sosp.zip Music in 4 Kilobytes - Size Optimized Synthesizer Programming]&lt;br /&gt;
* [https://iquilezles.org/articles/function2009/function2009.pdf Behind Elevated]&lt;br /&gt;
* [https://in4k.github.io/html_articles/Amietia%20%E2%80%A2%20The%20Making%20Of%20Oscar's%20Chair.html Making of Oscar's chair]&lt;br /&gt;
* [https://www.codeslow.com/2020/07/writing-winning-4k-intro-in-rust.html Article about writing a 4k intro using Rust]&lt;br /&gt;
* [https://in4k.github.io/wiki/aulds-4k-synth Article about writing a softsynth]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1832</id>
		<title>4K Intro</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1832"/>
				<updated>2025-11-03T23:53:46Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
This category is dedicated to modern 4K Intro development for [[Windows|Windows / Win32]], which consist of a small OpenGL/D3D/DX Framework, a softsynth and 1 or more pixelshaders. As such this won't be discussion legacy mesh techniques as few 4k intros make use of those techniques anymore.&lt;br /&gt;
&lt;br /&gt;
Most Windows 4K Intros will be setup using C, sometimes in combination with assembler, or in some cases pure assembler. In general writing everything in assembler should give you a little more freedom in pushing/popping your function arguments and register usage.&lt;br /&gt;
&lt;br /&gt;
Graphics are usualy done using OpenGL / GLSL or Direct3D/DX11.&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
There are a couple of options for tools, but generally these tools are often used&lt;br /&gt;
* Visual Studio / Vscode / GCC Compiler &lt;br /&gt;
* Crinkler or other external packer for compression ( https://crinkler.net )&lt;br /&gt;
* Shader minifier ( https://github.com/laurentlb/Shader_Minifier )&lt;br /&gt;
* Optional / Alternatively: NASM Assembler ( https://nasm.us/ )&lt;br /&gt;
* Optional: Local/Online GLSL Shader editing environment (e.g. Shadertoy, Kodelife, bonzo, etc.)&lt;br /&gt;
* Optional: Timeline/Camera tooling&lt;br /&gt;
* Optional: gnuRocket for timing.&lt;br /&gt;
&lt;br /&gt;
== Intro design ==&lt;br /&gt;
When designing a 4k intro, it is best practice to consider each of the following aspects seperately:&lt;br /&gt;
&lt;br /&gt;
* How much size budget do you want to allocate to render pipeline, sound, scene building, (post)shading, progression?&lt;br /&gt;
* Abstract vs organic vs scene/world-building &lt;br /&gt;
* Single scene vs multiple scenes&lt;br /&gt;
* Ray-Intersections or Ray Marching&lt;br /&gt;
* What kind of softsynth to use, or writing your own&lt;br /&gt;
* Render pipeline - Single or multipass (post/audio)shaders.&lt;br /&gt;
* Scene, Camera and progression handling&lt;br /&gt;
* Text - Do you want to include text and if so: Are you using WindowsGlyphs texture or SDF&lt;br /&gt;
&lt;br /&gt;
=== Design pitfalls ===&lt;br /&gt;
Here are a few design pitfalls you should try to avoid if necessary.&lt;br /&gt;
&lt;br /&gt;
==== Undirected raymarch experiments ====&lt;br /&gt;
Wiggly domain repetition shadertoy experiments, with or without walking glows, might be sufficient for a shaderjam or shader-showdown, but usually make a sub-par 4k intro. Don't do it, even if it has the compofiller banner on the slide.&lt;br /&gt;
  &lt;br /&gt;
====  The Rebranded cornell box - Just a shiny sphere bro! ==== &lt;br /&gt;
Its great as a rendertest reference for your PBR / pathtracing tests, but it doesn't make a compelling intro.&lt;br /&gt;
The times you still see a reflective/pathtraced sphere and/or box with music mask as a 4k intro is staggering. &lt;br /&gt;
Sadly sceners still accept these rebranded cornell boxes as legit and even winning/cdc receiving intros, because shineys.&lt;br /&gt;
But my intuition says these will be looked upon like the countless early 2000s goa+bended sphers/torus intros that fail to stand the test of time.&lt;br /&gt;
&lt;br /&gt;
====  Shitty synths ==== &lt;br /&gt;
There are a few great intros out there that have great visuals but are ruined by glopawful synths or music. If you are not good at music yourself, find yourself a musician to work with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Size Budgeting ==&lt;br /&gt;
A general rule of thumb is to work above the target size for most of the development and work your way down when the production is closer to completion.&lt;br /&gt;
&lt;br /&gt;
There are many ways to split the same bytes, here are the top-5 4K Intros at Revision 2024 that have made wildly different choices.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Ranking !! Intro Title !! Progression / Storytelling !! Object complexity || Graphics Fidelity !! Sound !! Notes !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Drifting Shore || Low || Low || Very-High || Low || Ray-Intersection + Pathtracing || https://demozoo.org/productions/342196/&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Dubplate || Medium || Low || High || Very-High || SDF Text || https://demozoo.org/productions/342202/&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Return to nature || High || High || Low || Low || - || https://demozoo.org/productions/342200/&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Brainfiller || Low || Medium || High || High || GLSL Softsynth || https://demozoo.org/productions/342203/&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Once Upon A Time In A Datacenter || High || Very-High || Low || Low || Custom CPU synthcode || https://demozoo.org/productions/342199/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Graphics fidelity ====&lt;br /&gt;
TBA&lt;br /&gt;
&lt;br /&gt;
==== Music budget ====&lt;br /&gt;
Got a musician to work with you and deliver a great tune? Don't accept it right out of the gate and feel free to argue about possible optimisations that can be done to the tune that will not affect the end-result massively. This is done by all of the better-known 4k intro developers and a good musician will be open to discussion and aware of the different limitation and choices that have to be made when it comes to size budgeting.&lt;br /&gt;
&lt;br /&gt;
== Setting up your framework ==&lt;br /&gt;
A 4k framework / intro can be setup in either C or Assembler, or a combination of both.&lt;br /&gt;
You can either go with an existing framework (some of them are quite capable) or build your own taylored to your own needs.&lt;br /&gt;
Also remember that even though there are many more ways to save size than in for example a 1k intro, that every byte saved here is one you can spent / budget elsewhere.&lt;br /&gt;
&lt;br /&gt;
* The groundlevel basics of a framework are discussed on the 1K Intro wiki at http://www.sizecoding.org/wiki/1K_Intro&lt;br /&gt;
* From here you can setup your audiobuffer add a softsynth of choice, or write your own (either in GLSL or Software)&lt;br /&gt;
* Most likely you'll like to add a few more function imports to properly pass uniforms to your shader.&lt;br /&gt;
* Optionally: Add another render-pass by feeding the output of the main shader to a post-shading process. This adds a few more texture calls to the framework&lt;br /&gt;
* Optionally: Add an init pass where you prepare (glyph) textures and other buffers you'd like to feed into your main shader.&lt;br /&gt;
* Optionally: Hook up a Scene/Camera/Timing system during development&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
Once you've budgeted and designed your intro, it is time to go to work. &lt;br /&gt;
&lt;br /&gt;
==== Prebuild your scene in an external tool ====&lt;br /&gt;
For convenience and turn-around time, its perfectly fine to use external online/offline tools like Shadertoy, Posh-Brolly, Kodelife, Bonzo or others to setup you main scene(s) / effects.&lt;br /&gt;
&lt;br /&gt;
==== Ray-Intersetions vs Raymarching ====&lt;br /&gt;
In theory ideally you'd like to have multi-sample, multiple bounces, highly flexible, highly accurate raymarching&lt;br /&gt;
But in practice this is as of year (2024) still impossible to do realtime on most systems, therefore a choice has to be made between exact interesctions of primitives / raytracing vs ray marching. What are the differences in usecases and what are their pros and cons:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Raymarching !! Ray-Intersection !! Examples&lt;br /&gt;
|-&lt;br /&gt;
| Domain-Repetition || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Fast Multi-Sample || No || Yes || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Twisting &amp;amp; Blending || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Shape-Blending || Yes || ? || TBA&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Post processing: Don't miss the low-hanging fruit ====&lt;br /&gt;
Having a proper post processing step can greatly improve the overall visual quality of your intro. So in 4k space i would suggest a postshader pass at minimum, which depending on your size budget you can use for things like Vignetting, DOF, tone-mapping, anti-aliasing, chromatic abberation, etc. &lt;br /&gt;
&lt;br /&gt;
But even if your 4k intro doesn't have a seperate post-shader pass, adding a bit of in-shader vignetting / gamma correction / tone-mapping to your intro are relative easy/cheap ways to improve visual quality of your intro, so why leave those options off the table?&lt;br /&gt;
For inspiration, You can check out the article at Here is an article at https://30fps.net/pages/post-processing/ for a few things you can do to improve your visuals in post.&lt;br /&gt;
&lt;br /&gt;
== Sound ==&lt;br /&gt;
Here is an overview of various Synths / Music options.&lt;br /&gt;
Depending on the exact track, you are looking at approx 1k - 1.5k compressed for music for most 4k intros.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Synth !! Type !! Description !! Size overhead !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 4klang || Subtractive || Most popular softsynth || Medium (1 note, 1 instrument at 620b) || https://github.com/gopher-atz/4klang&lt;br /&gt;
|-&lt;br /&gt;
| Sointu || Subtractive || 4klang fork with improvements || Medium (1 note, 1 instrument at 562b )|| https://github.com/vsariola/sointu/&lt;br /&gt;
|-&lt;br /&gt;
| Oidos || Additive || - || Medium (1 note, 1 instrument at 600b) || https://github.com/askeksa/Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Clinkster || FM || - || Medium (1 note, 1 instrument at 590b) || http://crinkler.net/Clinkster.zip&lt;br /&gt;
|-&lt;br /&gt;
| GLSL Softsynth || - || Write it yourself || Small/Medium (depends on usecase) || -&lt;br /&gt;
|-&lt;br /&gt;
| MIDI Player || MIDI || Using default Windows midi sounds || Small/Medium (depends on player/song complexity) || -&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As a snapshot. Here is a list of intros from 2017 with the synth they used:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Absolute Territory || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Waillee || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| final stage || Custom&lt;br /&gt;
|-&lt;br /&gt;
| Horizon Machine || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Unprogress || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Faraday Future || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Alive Here Now, Forever || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Destination Unknown || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| w a y f a r e r || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| HAL 4000 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Equilibrium || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| visit berlin || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| お花見 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Gary Glitter || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Superfine || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Cycle Of Nature || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Oxano || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Those Who Leave || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Maintenance || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Joia || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Back to the Roots || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Dropletia || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| crystalline lord || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| highrider || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Primordial Soup || Custom&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
Crinkler is the most commonly used compression at the moment for 4K intros. It maximizes compression by taking over the linking process, setting up the windows header for you and if needed re-arrange the different segments of the code.&lt;br /&gt;
&lt;br /&gt;
==== Crinkler reports ====&lt;br /&gt;
When using the &amp;lt;code&amp;gt;/REPORT:intro_report.html&amp;lt;/code&amp;gt; feature, crinkler will generate a report and heatmap for your intro binary.&lt;br /&gt;
This is helpful to see how well your (shader)code compresses and where you can maybe gain a few more bytes.&lt;br /&gt;
&lt;br /&gt;
==== Word about the resulting executable ====&lt;br /&gt;
Please note that when using crinkler in TINYHEADER mode, the resulting windows header will most likely trigger virus scanners / Microsoft Defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice  to include a (slightly larger) safe version too in the final archive.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
==== Frameworks ====&lt;br /&gt;
* [https://github.com/armak/Leviathan-2.0 Leviathan 2.0]&lt;br /&gt;
* [https://github.com/in4k/isystem1k4k IQ's 1k/4k frameworks]&lt;br /&gt;
* [https://github.com/psycholns/TinyDX11 Psycho's 1k/4k framework]&lt;br /&gt;
* [http://www.kameli.net/compofillerstudio/ Compofiller studio]&lt;br /&gt;
* [https://github.com/yosshin4004/minimal_gl Minimal gl framework]&lt;br /&gt;
* [https://github.com/Beluki/4kGL 4KGL framework]&lt;br /&gt;
* [https://github.com/w23/bepct4k Bepct4k]&lt;br /&gt;
&lt;br /&gt;
==== Raymarching ====&lt;br /&gt;
* [https://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions/ Introduction to Raymarching]&lt;br /&gt;
* [https://iquilezles.org/articles/distfunctions/ IQ's distance functions page]&lt;br /&gt;
* [https://mercury.sexy/hg_sdf/ Mercury's SDF toolbox]&lt;br /&gt;
&lt;br /&gt;
==== High Quality 4K intros for Windows ====&lt;br /&gt;
* [https://demozoo.org/productions/371094/ Hexer (2025)]&lt;br /&gt;
* [https://demozoo.org/productions/355449/ XO (2024)]&lt;br /&gt;
* [https://demozoo.org/productions/331908/ Architectural Shapeshifter (2023)]&lt;br /&gt;
* [https://demozoo.org/productions/311778/ Stahlbeton (2022)]&lt;br /&gt;
* [https://demozoo.org/productions/278629/ The Vanishing of Ashlar (2020)]&lt;br /&gt;
* [https://demozoo.org/productions/266556/ Eisenerz (2019)]&lt;br /&gt;
* [https://demozoo.org/productions/185233/ Oscar's Chair (2018)]&lt;br /&gt;
* [https://demozoo.org/productions/174689/ Unprogress (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/178895/ Waillee (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/170744/ Horizon Machine (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/91680/ Neuron (2013)]&lt;br /&gt;
* [https://demozoo.org/productions/102/ Elevated (2009)]&lt;br /&gt;
* [https://demozoo.org/productions/4846/ Atrium (2008)]&lt;br /&gt;
&lt;br /&gt;
==== 4K intros for Windows with Sourcecode ====&lt;br /&gt;
* [https://github.com/friol/planetx Planet X (2025)]&lt;br /&gt;
* [https://github.com/vsariola/dipping-deep-dub-drop/tree/master Dipping deep dub drop (2025)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2024-08_4k-intro_olkiluoto_3-2-1 Olkiluoto 3-1-1 (2024)]&lt;br /&gt;
* [https://github.com/0b5vr/brainfiller Brainfiller (2024)]&lt;br /&gt;
* [https://github.com/TheNuSan/Lev4k/tree/DriftingShore Drifting Shore (2024)]&lt;br /&gt;
* [https://github.com/vsariola/every-datapoint Every Datapoint has a soul (2024)]&lt;br /&gt;
* [https://github.com/Krafpy/Island/tree/master/ Island (2024)] &lt;br /&gt;
* [https://github.com/LeStahL/ontrack-4k physics girl (2023)]&lt;br /&gt;
* [https://github.com/vsariola/fluxerator Fluxerator (2023)]&lt;br /&gt;
* [https://github.com/vsariola/adam Adam (2021)]&lt;br /&gt;
* [https://github.com/LeStahL/abstraction-confusion Abstraction Confusion (2021)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2019-08_4k-intro_region_de_magallanes Region de Magallanes (2019)]&lt;br /&gt;
* [https://github.com/demoscene-source-archive/oscar-s-chair Oscar's Chair (2018)]&lt;br /&gt;
* [https://github.com/w23/jetlag_appear Appear (2018)]&lt;br /&gt;
* [https://github.com/w23/jetlag_posle Posle (2018)]&lt;br /&gt;
* [https://github.com/w23/nwep nwep (2017)]&lt;br /&gt;
* [https://github.com/keensky/hal4000 Hall4000 (2017)]&lt;br /&gt;
* [https://github.com/in4k/rgba_tbc_elevated_source Elevated (2009)]&lt;br /&gt;
&lt;br /&gt;
==== Seminars ====&lt;br /&gt;
* [https://www.youtube.com/watch?v=S-VDVgCBy-M Shader minification for 4k - 64k intros (2023)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=xLhT06lwaig 4klang 101 - Basics (2019)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=Ir0vcmHkIm0 nstalling and trying out different synths for 4kb intros (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=9BqKH0XNN-g Size Restricted music isn't Rocketscience (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=wP__g_9FT4M Sound Design with 4klang, by Wayfinder (2015)]&lt;br /&gt;
&lt;br /&gt;
==== Articles ====&lt;br /&gt;
* [ftp://ftp.untergrund.net/users/thygrion/sosp.zip Music in 4 Kilobytes - Size Optimized Synthesizer Programming]&lt;br /&gt;
* [https://iquilezles.org/articles/function2009/function2009.pdf Behind Elevated]&lt;br /&gt;
* [https://in4k.github.io/html_articles/Amietia%20%E2%80%A2%20The%20Making%20Of%20Oscar's%20Chair.html Making of Oscar's chair]&lt;br /&gt;
* [https://www.codeslow.com/2020/07/writing-winning-4k-intro-in-rust.html Article about writing a 4k intro using Rust]&lt;br /&gt;
* [https://in4k.github.io/wiki/aulds-4k-synth Article about writing a softsynth]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1831</id>
		<title>4K Intro</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1831"/>
				<updated>2025-11-03T23:52:07Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
This category is dedicated to modern 4K Intro development for [[Windows|Windows / Win32]], which consist of a small OpenGL/D3D/DX Framework, a softsynth and 1 or more pixelshaders. As such this won't be discussion legacy mesh techniques as few 4k intros make use of those techniques anymore.&lt;br /&gt;
&lt;br /&gt;
Most Windows 4K Intros will be setup using C, sometimes in combination with assembler, or in some cases pure assembler. In general writing everything in assembler should give you a little more freedom in pushing/popping your function arguments and register usage.&lt;br /&gt;
&lt;br /&gt;
Graphics are usualy done using OpenGL / GLSL or Direct3D/DX11.&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
There are a couple of options for tools, but generally these tools are often used&lt;br /&gt;
* Visual Studio / Vscode / GCC Compiler &lt;br /&gt;
* Crinkler or other external packer for compression ( https://crinkler.net )&lt;br /&gt;
* Shader minifier ( https://github.com/laurentlb/Shader_Minifier )&lt;br /&gt;
* Optional / Alternatively: NASM Assembler ( https://nasm.us/ )&lt;br /&gt;
* Optional: Local/Online GLSL Shader editing environment (e.g. Shadertoy, Kodelife, bonzo, etc.)&lt;br /&gt;
* Optional: Timeline/Camera tooling&lt;br /&gt;
* Optional: gnuRocket for timing.&lt;br /&gt;
&lt;br /&gt;
== Intro design ==&lt;br /&gt;
When designing a 4k intro, it is best practice to consider each of the following aspects seperately:&lt;br /&gt;
&lt;br /&gt;
* How much size budget do you want to allocate to render pipeline, sound, scene building, (post)shading, progression?&lt;br /&gt;
* Abstract vs organic vs scene/world-building &lt;br /&gt;
* Single scene vs multiple scenes&lt;br /&gt;
* Ray-Intersections or Ray Marching&lt;br /&gt;
* What kind of softsynth to use, or writing your own&lt;br /&gt;
* Render pipeline - Single or multipass (post/audio)shaders.&lt;br /&gt;
* Scene, Camera and progression handling&lt;br /&gt;
* Text - Do you want to include text and if so: Are you using WindowsGlyphs texture or SDF&lt;br /&gt;
&lt;br /&gt;
=== Design pitfalls ===&lt;br /&gt;
Here are a few design pitfalls you should try to avoid if necessary.&lt;br /&gt;
&lt;br /&gt;
==== Undirected raymarch experiments ====&lt;br /&gt;
Wiggly domain repetition shadertoy experiments, with or without walking glows, might be sufficient for a shaderjam or shader-showdown, but usually make a sub-par 4k intro. Don't do it, even if it has the compofiller banner on the slide.&lt;br /&gt;
  &lt;br /&gt;
====  The Rebranded cornell box - Just a shiny sphere bro! ==== &lt;br /&gt;
Its great as a rendertest reference for your PBR / pathtracing tests, but it doesn't make a compelling intro.&lt;br /&gt;
The times you still see a reflective/pathtraced sphere and/or box with music mask as a 4k intro is staggering. &lt;br /&gt;
Sadly sceners still accept these rebranded cornell boxes as legit and even winning/cdc receiving intros, because shineys.&lt;br /&gt;
But my intuition says these will be looked upon like the countless early 2000s goa+bended sphers/torus intros that fail to stand the test of time.&lt;br /&gt;
&lt;br /&gt;
====  Shitty synths ==== &lt;br /&gt;
There are a few great intros out there that have great visuals but are ruined by glopawful synths or music. If you are not good at music yourself, find yourself a musician to work with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Size Budgeting ==&lt;br /&gt;
A general rule of thumb is to work above the target size for most of the development and work your way down when the production is closer to completion.&lt;br /&gt;
&lt;br /&gt;
There are many ways to split the same bytes, here are the top-5 4K Intros at Revision 2024 that have made wildly different choices.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Ranking !! Intro Title !! Progression / Storytelling !! Object complexity || Graphics Fidelity !! Sound !! Notes !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Drifting Shore || Low || Low || Very-High || Low || Ray-Intersection + Pathtracing || https://demozoo.org/productions/342196/&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Dubplate || Medium || Low || High || Very-High || SDF Text || https://demozoo.org/productions/342202/&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Return to nature || High || High || Low || Low || - || https://demozoo.org/productions/342200/&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Brainfiller || Low || Medium || High || High || GLSL Softsynth || https://demozoo.org/productions/342203/&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Once Upon A Time In A Datacenter || High || Very-High || Low || Low || Custom CPU synthcode || https://demozoo.org/productions/342199/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Graphics fidelity ====&lt;br /&gt;
TBA&lt;br /&gt;
&lt;br /&gt;
==== Music budget ====&lt;br /&gt;
Got a musician to work with you and deliver a great tune? Don't accept it right out of the gate and feel free to argue about possible optimisations that can be done to the tune that will not affect the end-result massively. This is done by all of the better-known 4k intro developers and a good musician will be open to discussion and aware of the different limitation and choices that have to be made when it comes to size budgeting.&lt;br /&gt;
&lt;br /&gt;
== Setting up your framework ==&lt;br /&gt;
A 4k framework / intro can be setup in either C or Assembler, or a combination of both.&lt;br /&gt;
You can either go with an existing framework (some of them are quite capable) or build your own taylored to your own needs.&lt;br /&gt;
Also remember that even though there are many more ways to save size than in for example a 1k intro, that every byte saved here is one you can spent / budget elsewhere.&lt;br /&gt;
&lt;br /&gt;
* The groundlevel basics of a framework are discussed on the 1K Intro wiki at http://www.sizecoding.org/wiki/1K_Intro&lt;br /&gt;
* From here you can setup your audiobuffer add a softsynth of choice, or write your own (either in GLSL or Software)&lt;br /&gt;
* Most likely you'll like to add a few more function imports to properly pass uniforms to your shader.&lt;br /&gt;
* Optionally: Add another render-pass by feeding the output of the main shader to a post-shading process. This adds a few more texture calls to the framework&lt;br /&gt;
* Optionally: Add an init pass where you prepare (glyph) textures and other buffers you'd like to feed into your main shader.&lt;br /&gt;
* Optionally: Hook up a Scene/Camera/Timing system during development&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
Once you've budgeted and designed your intro, it is time to go to work. &lt;br /&gt;
&lt;br /&gt;
==== Prebuild your scene in an external tool ====&lt;br /&gt;
For convenience and turn-around time, its perfectly fine to use external online/offline tools like Shadertoy, Posh-Brolly, Kodelife, Bonzo or others to setup you main scene(s) / effects.&lt;br /&gt;
&lt;br /&gt;
==== Ray-Intersetions vs Raymarching ====&lt;br /&gt;
In theory ideally you'd like to have multi-sample, multiple bounces, highly flexible, highly accurate raymarching&lt;br /&gt;
But in practice this is as of year (2024) still impossible to do realtime on most systems, therefore a choice has to be made between exact interesctions of primitives / raytracing vs ray marching. What are the differences in usecases and what are their pros and cons:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Raymarching !! Ray-Intersection !! Examples&lt;br /&gt;
|-&lt;br /&gt;
| Domain-Repetition || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Fast Multi-Sample || No || Yes || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Twisting &amp;amp; Blending || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Shape-Blending || Yes || ? || TBA&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Post processing: Don't miss the low-hanging fruit ====&lt;br /&gt;
Having a proper post processing step can greatly improve the overall visual quality of your intro. So in 4k space i would suggest a postshader pass at minimum, which depending on your size budget you can use for things like Vignetting, DOF, tone-mapping, anti-aliasing, chromatic abberation, etc. &lt;br /&gt;
&lt;br /&gt;
But even if your 4k intro doesn't have a seperate post-shader pass, adding a bit of in-shader vignetting / gamma correction / tone-mapping to your intro are relative easy/cheap ways to improve visual quality of your intro, so why leave those options off the table?&lt;br /&gt;
For inspiration, You can check out the article at Here is an article at https://30fps.net/pages/post-processing/ for a few things you can do to improve your visuals in post.&lt;br /&gt;
&lt;br /&gt;
== Sound ==&lt;br /&gt;
Here is an overview of various Synths / Music options.&lt;br /&gt;
Depending on the exact track, you are looking at approx 1k - 1.5k compressed for music for most 4k intros.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Synth !! Type !! Description !! Size overhead !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 4klang || Subtractive || Most popular softsynth || Medium (1 note, 1 instrument at 620b) || https://github.com/gopher-atz/4klang&lt;br /&gt;
|-&lt;br /&gt;
| Sointu || Subtractive || 4klang fork with improvements || Medium (1 note, 1 instrument at 562b )|| https://github.com/vsariola/sointu/&lt;br /&gt;
|-&lt;br /&gt;
| Oidos || Additive || - || Medium (1 note, 1 instrument at 600b) || https://github.com/askeksa/Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Clinkster || FM || - || Medium (1 note, 1 instrument at 590b) || http://crinkler.net/Clinkster.zip&lt;br /&gt;
|-&lt;br /&gt;
| GLSL Softsynth || - || Write it yourself || Small/Medium (depends on usecase) || -&lt;br /&gt;
|-&lt;br /&gt;
| MIDI Player || MIDI || Using default Windows midi sounds || Small/Medium (depends on player/song complexity) || -&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As a snapshot. Here is a list of intros from 2017 with the synth they used:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Absolute Territory || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Waillee || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| final stage || Custom&lt;br /&gt;
|-&lt;br /&gt;
| Horizon Machine || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Unprogress || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Faraday Future || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Alive Here Now, Forever || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Destination Unknown || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| w a y f a r e r || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| HAL 4000 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Equilibrium || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| visit berlin || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| お花見 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Gary Glitter || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Superfine || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Cycle Of Nature || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Oxano || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Those Who Leave || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Maintenance || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Joia || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Back to the Roots || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Dropletia || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| crystalline lord || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| highrider || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Primordial Soup || Custom&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
Crinkler is the most commonly used compression at the moment for 4K intros. It maximizes compression by taking over the linking process, setting up the windows header for you and if needed re-arrange the different segments of the code.&lt;br /&gt;
&lt;br /&gt;
==== Crinkler reports ====&lt;br /&gt;
When using the &amp;lt;code&amp;gt;/REPORT:intro_report.html&amp;lt;/code&amp;gt; feature, crinkler will generate a report and heatmap for your intro binary.&lt;br /&gt;
This is helpful to see how well your (shader)code compresses and where you can maybe gain a few more bytes.&lt;br /&gt;
&lt;br /&gt;
==== Word about the resulting executable ====&lt;br /&gt;
Please note that when using crinkler in TINYHEADER mode, the resulting windows header will most likely trigger virus scanners / Microsoft Defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice  to include a (slightly larger) safe version too in the final archive.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
==== Frameworks ====&lt;br /&gt;
* [https://github.com/armak/Leviathan-2.0 Leviathan 2.0]&lt;br /&gt;
* [https://github.com/in4k/isystem1k4k IQ's 1k/4k frameworks]&lt;br /&gt;
* [https://github.com/psycholns/TinyDX11 Psycho's 1k/4k framework]&lt;br /&gt;
* [http://www.kameli.net/compofillerstudio/ Compofiller studio]&lt;br /&gt;
* [https://github.com/yosshin4004/minimal_gl Minimal gl framework]&lt;br /&gt;
* [https://github.com/Beluki/4kGL 4KGL framework]&lt;br /&gt;
* [https://github.com/w23/bepct4k Bepct4k]&lt;br /&gt;
&lt;br /&gt;
==== Raymarching ====&lt;br /&gt;
* [https://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions/ Introduction to Raymarching]&lt;br /&gt;
* [https://iquilezles.org/articles/distfunctions/ IQ's distance functions page]&lt;br /&gt;
* [https://mercury.sexy/hg_sdf/ Mercury's SDF toolbox]&lt;br /&gt;
&lt;br /&gt;
==== High Quality 4K intros for Windows ====&lt;br /&gt;
* [https://demozoo.org/productions/371094/ Hexer (2025)]&lt;br /&gt;
* [https://demozoo.org/productions/355449/ XO (2024)]&lt;br /&gt;
* [https://demozoo.org/productions/331908/ Architectural Shapeshifter (2023)]&lt;br /&gt;
* [https://demozoo.org/productions/311778/ Stahlbeton (2022)]&lt;br /&gt;
* [https://demozoo.org/productions/278629/ The Vanishing of Ashlar (2020)]&lt;br /&gt;
* [https://demozoo.org/productions/266556/ Eisenerz (2019)]&lt;br /&gt;
* [https://demozoo.org/productions/185233/ Oscar's Chair (2018)]&lt;br /&gt;
* [https://demozoo.org/productions/174689/ Unprogress (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/178895/ Waillee (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/170744/ Horizon Machine (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/91680/ Neuron (2013)]&lt;br /&gt;
* [https://demozoo.org/productions/102/ Elevated (2009)]&lt;br /&gt;
* [https://demozoo.org/productions/4846/ Atrium (2008)]&lt;br /&gt;
&lt;br /&gt;
==== 4K intros for Windows with Sourcecode ====&lt;br /&gt;
* [https://github.com/friol/planetx Planet X (2025)]&lt;br /&gt;
* [https://github.com/vsariola/dipping-deep-dub-drop/tree/master Dipping deep dub drop (2025)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2024-08_4k-intro_olkiluoto_3-2-1 Olkiluoto 3-1-1 (2024)]&lt;br /&gt;
* [https://github.com/0b5vr/brainfiller Brainfiller (2024)]&lt;br /&gt;
* [https://github.com/TheNuSan/Lev4k/tree/DriftingShore Drifting Shore (2024)]&lt;br /&gt;
* [https://github.com/vsariola/every-datapoint Every Datapoint has a soul (2024)]&lt;br /&gt;
* [https://github.com/Krafpy/Island/tree/master/ Island (2024)] &lt;br /&gt;
* [https://github.com/LeStahL/ontrack-4k physics girl (2023)]&lt;br /&gt;
* [https://github.com/vsariola/fluxerator Fluxerator (2023)]&lt;br /&gt;
* [https://github.com/vsariola/adam Adam (2021)]&lt;br /&gt;
* [https://github.com/LeStahL/abstraction-confusion Abstraction Confusion (2021)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2019-08_4k-intro_region_de_magallanes Region de Magallanes (2019)]&lt;br /&gt;
* [https://github.com/demoscene-source-archive/oscar-s-chair Oscar's Chair (2018)]&lt;br /&gt;
* [https://github.com/w23/jetlag_appear Appear (2018)]&lt;br /&gt;
* [https://github.com/w23/nwep nwep (2017)]&lt;br /&gt;
* [https://github.com/keensky/hal4000 Hall4000 (2017)]&lt;br /&gt;
* [https://github.com/in4k/rgba_tbc_elevated_source Elevated (2009)]&lt;br /&gt;
&lt;br /&gt;
==== Seminars ====&lt;br /&gt;
* [https://www.youtube.com/watch?v=S-VDVgCBy-M Shader minification for 4k - 64k intros (2023)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=xLhT06lwaig 4klang 101 - Basics (2019)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=Ir0vcmHkIm0 nstalling and trying out different synths for 4kb intros (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=9BqKH0XNN-g Size Restricted music isn't Rocketscience (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=wP__g_9FT4M Sound Design with 4klang, by Wayfinder (2015)]&lt;br /&gt;
&lt;br /&gt;
==== Articles ====&lt;br /&gt;
* [ftp://ftp.untergrund.net/users/thygrion/sosp.zip Music in 4 Kilobytes - Size Optimized Synthesizer Programming]&lt;br /&gt;
* [https://iquilezles.org/articles/function2009/function2009.pdf Behind Elevated]&lt;br /&gt;
* [https://in4k.github.io/html_articles/Amietia%20%E2%80%A2%20The%20Making%20Of%20Oscar's%20Chair.html Making of Oscar's chair]&lt;br /&gt;
* [https://www.codeslow.com/2020/07/writing-winning-4k-intro-in-rust.html Article about writing a 4k intro using Rust]&lt;br /&gt;
* [https://in4k.github.io/wiki/aulds-4k-synth Article about writing a softsynth]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1830</id>
		<title>4K Intro</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1830"/>
				<updated>2025-11-03T23:44:19Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
This category is dedicated to modern 4K Intro development for [[Windows|Windows / Win32]], which consist of a small OpenGL/D3D/DX Framework, a softsynth and 1 or more pixelshaders. As such this won't be discussion legacy mesh techniques as few 4k intros make use of those techniques anymore.&lt;br /&gt;
&lt;br /&gt;
Most Windows 4K Intros will be setup using C, sometimes in combination with assembler, or in some cases pure assembler. In general writing everything in assembler should give you a little more freedom in pushing/popping your function arguments and register usage.&lt;br /&gt;
&lt;br /&gt;
Graphics are usualy done using OpenGL / GLSL or Direct3D/DX11.&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
There are a couple of options for tools, but generally these tools are often used&lt;br /&gt;
* Visual Studio / Vscode / GCC Compiler &lt;br /&gt;
* Crinkler or other external packer for compression ( https://crinkler.net )&lt;br /&gt;
* Shader minifier ( https://github.com/laurentlb/Shader_Minifier )&lt;br /&gt;
* Optional / Alternatively: NASM Assembler ( https://nasm.us/ )&lt;br /&gt;
* Optional: Local/Online GLSL Shader editing environment (e.g. Shadertoy, Kodelife, bonzo, etc.)&lt;br /&gt;
* Optional: Timeline/Camera tooling&lt;br /&gt;
* Optional: gnuRocket for timing.&lt;br /&gt;
&lt;br /&gt;
== Intro design ==&lt;br /&gt;
When designing a 4k intro, it is best practice to consider each of the following aspects seperately:&lt;br /&gt;
&lt;br /&gt;
* How much size budget do you want to allocate to render pipeline, sound, scene building, (post)shading, progression?&lt;br /&gt;
* Abstract vs organic vs scene/world-building &lt;br /&gt;
* Single scene vs multiple scenes&lt;br /&gt;
* Ray-Intersections or Ray Marching&lt;br /&gt;
* What kind of softsynth to use, or writing your own&lt;br /&gt;
* Render pipeline - Single or multipass (post/audio)shaders.&lt;br /&gt;
* Scene, Camera and progression handling&lt;br /&gt;
* Text - Do you want to include text and if so: Are you using WindowsGlyphs texture or SDF&lt;br /&gt;
&lt;br /&gt;
=== Design pitfalls ===&lt;br /&gt;
Here are a few design pitfalls you should try to avoid if necessary.&lt;br /&gt;
&lt;br /&gt;
==== Undirected raymarch experiments ====&lt;br /&gt;
Wiggly domain repetition shadertoy experiments, with or without walking glows, might be sufficient for a shaderjam or shader-showdown, but usually make a sub-par 4k intro. Don't do it, even if it has the compofiller banner on the slide.&lt;br /&gt;
  &lt;br /&gt;
====  The Rebranded cornell box - Just a shiny sphere bro! ==== &lt;br /&gt;
Its great as a rendertest reference for your PBR / pathtracing tests, but it doesn't make a compelling intro.&lt;br /&gt;
The times you still see a reflective/pathtraced sphere and/or box with music mask as a 4k intro is staggering. &lt;br /&gt;
Sadly sceners still accept these rebranded cornell boxes as legit and even winning/cdc receiving intros, because shineys.&lt;br /&gt;
But my intuition says these will be looked upon like the countless early 2000s goa+bended sphers/torus intros that fail to stand the test of time.&lt;br /&gt;
&lt;br /&gt;
====  Shitty synths ==== &lt;br /&gt;
There are a few great intros out there that have great visuals but are ruined by glopawful synths or music. If you are not good at music yourself, find yourself a musician to work with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Size Budgeting ==&lt;br /&gt;
A general rule of thumb is to work above the target size for most of the development and work your way down when the production is closer to completion.&lt;br /&gt;
&lt;br /&gt;
There are many ways to split the same bytes, here are the top-5 4K Intros at Revision 2024 that have made wildly different choices.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Ranking !! Intro Title !! Progression / Storytelling !! Object complexity || Graphics Fidelity !! Sound !! Notes !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Drifting Shore || Low || Low || Very-High || Low || Ray-Intersection + Pathtracing || https://demozoo.org/productions/342196/&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Dubplate || Medium || Low || High || Very-High || SDF Text || https://demozoo.org/productions/342202/&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Return to nature || High || High || Low || Low || - || https://demozoo.org/productions/342200/&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Brainfiller || Low || Medium || High || High || GLSL Softsynth || https://demozoo.org/productions/342203/&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Once Upon A Time In A Datacenter || High || Very-High || Low || Low || Custom CPU synthcode || https://demozoo.org/productions/342199/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Graphics fidelity ====&lt;br /&gt;
TBA&lt;br /&gt;
&lt;br /&gt;
==== Music budget ====&lt;br /&gt;
Got a musician to work with you and deliver a great tune? Don't accept it right out of the gate and feel free to argue about possible optimisations that can be done to the tune that will not affect the end-result massively. This is done by all of the better-known 4k intro developers and a good musician will be open to discussion and aware of the different limitation and choices that have to be made when it comes to size budgeting.&lt;br /&gt;
&lt;br /&gt;
== Setting up your framework ==&lt;br /&gt;
A 4k framework / intro can be setup in either C or Assembler, or a combination of both.&lt;br /&gt;
You can either go with an existing framework (some of them are quite capable) or build your own taylored to your own needs.&lt;br /&gt;
Also remember that even though there are many more ways to save size than in for example a 1k intro, that every byte saved here is one you can spent / budget elsewhere.&lt;br /&gt;
&lt;br /&gt;
* The groundlevel basics of a framework are discussed on the 1K Intro wiki at http://www.sizecoding.org/wiki/1K_Intro&lt;br /&gt;
* From here you can setup your audiobuffer add a softsynth of choice, or write your own (either in GLSL or Software)&lt;br /&gt;
* Most likely you'll like to add a few more function imports to properly pass uniforms to your shader.&lt;br /&gt;
* Optionally: Add another render-pass by feeding the output of the main shader to a post-shading process. This adds a few more texture calls to the framework&lt;br /&gt;
* Optionally: Add an init pass where you prepare (glyph) textures and other buffers you'd like to feed into your main shader.&lt;br /&gt;
* Optionally: Hook up a Scene/Camera/Timing system during development&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
Once you've budgeted and designed your intro, it is time to go to work. &lt;br /&gt;
&lt;br /&gt;
==== Prebuild your scene in an external tool ====&lt;br /&gt;
For convenience and turn-around time, its perfectly fine to use external online/offline tools like Shadertoy, Posh-Brolly, Kodelife, Bonzo or others to setup you main scene(s) / effects.&lt;br /&gt;
&lt;br /&gt;
==== Ray-Intersetions vs Raymarching ====&lt;br /&gt;
In theory ideally you'd like to have multi-sample, multiple bounces, highly flexible, highly accurate raymarching&lt;br /&gt;
But in practice this is as of year (2024) still impossible to do realtime on most systems, therefore a choice has to be made between exact interesctions of primitives / raytracing vs ray marching. What are the differences in usecases and what are their pros and cons:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Raymarching !! Ray-Intersection !! Examples&lt;br /&gt;
|-&lt;br /&gt;
| Domain-Repetition || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Fast Multi-Sample || No || Yes || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Twisting &amp;amp; Blending || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Shape-Blending || Yes || ? || TBA&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Post processing: Don't miss the low-hanging fruit ====&lt;br /&gt;
Having a proper post processing step can greatly improve the overall visual quality of your intro. So in 4k space i would suggest a postshader pass at minimum, which depending on your size budget you can use for things like Vignetting, DOF, tone-mapping, anti-aliasing, chromatic abberation, etc. &lt;br /&gt;
&lt;br /&gt;
But even if your 4k intro doesn't have a seperate post-shader pass, adding a bit of in-shader vignetting / gamma correction / tone-mapping to your intro are relative easy/cheap ways to improve visual quality of your intro, so why leave those options off the table?&lt;br /&gt;
For inspiration, You can check out the article at Here is an article at https://30fps.net/pages/post-processing/ for a few things you can do to improve your visuals in post.&lt;br /&gt;
&lt;br /&gt;
== Sound ==&lt;br /&gt;
Here is an overview of various Synths / Music options.&lt;br /&gt;
Depending on the exact track, you are looking at approx 1k - 1.5k compressed for music for most 4k intros.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Synth !! Type !! Description !! Size overhead !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 4klang || Subtractive || Most popular softsynth || Medium (1 note, 1 instrument at 620b) || https://github.com/gopher-atz/4klang&lt;br /&gt;
|-&lt;br /&gt;
| Sointu || Subtractive || 4klang fork with improvements || Medium (1 note, 1 instrument at 562b )|| https://github.com/vsariola/sointu/&lt;br /&gt;
|-&lt;br /&gt;
| Oidos || Additive || - || Medium (1 note, 1 instrument at 600b) || https://github.com/askeksa/Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Clinkster || FM || - || Medium (1 note, 1 instrument at 590b) || http://crinkler.net/Clinkster.zip&lt;br /&gt;
|-&lt;br /&gt;
| GLSL Softsynth || - || Write it yourself || Small/Medium (depends on usecase) || -&lt;br /&gt;
|-&lt;br /&gt;
| MIDI Player || MIDI || Using default Windows midi sounds || Small/Medium (depends on player/song complexity) || -&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As a snapshot. Here is a list of intros from 2017 with the synth they used:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Absolute Territory || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Waillee || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| final stage || Custom&lt;br /&gt;
|-&lt;br /&gt;
| Horizon Machine || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Unprogress || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Faraday Future || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Alive Here Now, Forever || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Destination Unknown || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| w a y f a r e r || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| HAL 4000 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Equilibrium || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| visit berlin || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| お花見 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Gary Glitter || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Superfine || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Cycle Of Nature || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Oxano || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Those Who Leave || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Maintenance || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Joia || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Back to the Roots || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Dropletia || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| crystalline lord || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| highrider || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Primordial Soup || Custom&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
Crinkler is the most commonly used compression at the moment for 4K intros. It maximizes compression by taking over the linking process, setting up the windows header for you and if needed re-arrange the different segments of the code.&lt;br /&gt;
&lt;br /&gt;
==== Crinkler reports ====&lt;br /&gt;
When using the &amp;lt;code&amp;gt;/REPORT:intro_report.html&amp;lt;/code&amp;gt; feature, crinkler will generate a report and heatmap for your intro binary.&lt;br /&gt;
This is helpful to see how well your (shader)code compresses and where you can maybe gain a few more bytes.&lt;br /&gt;
&lt;br /&gt;
==== Word about the resulting executable ====&lt;br /&gt;
Please note that when using crinkler in TINYHEADER mode, the resulting windows header will most likely trigger virus scanners / Microsoft Defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice  to include a (slightly larger) safe version too in the final archive.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
==== Frameworks ====&lt;br /&gt;
* [https://github.com/armak/Leviathan-2.0 Leviathan 2.0]&lt;br /&gt;
* [https://github.com/in4k/isystem1k4k IQ's 1k/4k frameworks]&lt;br /&gt;
* [https://github.com/psycholns/TinyDX11 Psycho's 1k/4k framework]&lt;br /&gt;
* [http://www.kameli.net/compofillerstudio/ Compofiller studio]&lt;br /&gt;
* [https://github.com/yosshin4004/minimal_gl Minimal gl framework]&lt;br /&gt;
* [https://github.com/Beluki/4kGL 4KGL framework]&lt;br /&gt;
&lt;br /&gt;
==== Raymarching ====&lt;br /&gt;
* [https://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions/ Introduction to Raymarching]&lt;br /&gt;
* [https://iquilezles.org/articles/distfunctions/ IQ's distance functions page]&lt;br /&gt;
* [https://mercury.sexy/hg_sdf/ Mercury's SDF toolbox]&lt;br /&gt;
&lt;br /&gt;
==== High Quality 4K intros for Windows ====&lt;br /&gt;
* [https://demozoo.org/productions/371094/ Hexer (2025)]&lt;br /&gt;
* [https://demozoo.org/productions/355449/ XO (2024)]&lt;br /&gt;
* [https://demozoo.org/productions/331908/ Architectural Shapeshifter (2023)]&lt;br /&gt;
* [https://demozoo.org/productions/311778/ Stahlbeton (2022)]&lt;br /&gt;
* [https://demozoo.org/productions/278629/ The Vanishing of Ashlar (2020)]&lt;br /&gt;
* [https://demozoo.org/productions/266556/ Eisenerz (2019)]&lt;br /&gt;
* [https://demozoo.org/productions/185233/ Oscar's Chair (2018)]&lt;br /&gt;
* [https://demozoo.org/productions/174689/ Unprogress (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/178895/ Waillee (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/170744/ Horizon Machine (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/91680/ Neuron (2013)]&lt;br /&gt;
* [https://demozoo.org/productions/102/ Elevated (2009)]&lt;br /&gt;
* [https://demozoo.org/productions/4846/ Atrium (2008)]&lt;br /&gt;
&lt;br /&gt;
==== 4K intros for Windows with Sourcecode ====&lt;br /&gt;
* [https://github.com/friol/planetx Planet X (2025)]&lt;br /&gt;
* [https://github.com/vsariola/dipping-deep-dub-drop/tree/master Dipping deep dub drop (2025)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2024-08_4k-intro_olkiluoto_3-2-1 Olkiluoto 3-1-1 (2024)]&lt;br /&gt;
* [https://github.com/0b5vr/brainfiller Brainfiller (2024)]&lt;br /&gt;
* [https://github.com/TheNuSan/Lev4k/tree/DriftingShore Drifting Shore (2024)]&lt;br /&gt;
* [https://github.com/vsariola/every-datapoint Every Datapoint has a soul (2024)]&lt;br /&gt;
* [https://github.com/Krafpy/Island/tree/master/ Island (2024)] &lt;br /&gt;
* [https://github.com/LeStahL/ontrack-4k physics girl (2023)]&lt;br /&gt;
* [https://github.com/vsariola/fluxerator Fluxerator (2023)]&lt;br /&gt;
* [https://github.com/vsariola/adam Adam (2021)]&lt;br /&gt;
* [https://github.com/LeStahL/abstraction-confusion Abstraction Confusion (2021)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2019-08_4k-intro_region_de_magallanes Region de Magallanes (2019)]&lt;br /&gt;
* [https://github.com/demoscene-source-archive/oscar-s-chair Oscar's Chair (2018)]&lt;br /&gt;
* [https://github.com/w23/jetlag_appear Appear (2018)]&lt;br /&gt;
* [https://github.com/w23/nwep nwep (2017)]&lt;br /&gt;
* [https://github.com/keensky/hal4000 Hall4000 (2017)]&lt;br /&gt;
* [https://github.com/in4k/rgba_tbc_elevated_source Elevated (2009)]&lt;br /&gt;
&lt;br /&gt;
==== Seminars ====&lt;br /&gt;
* [https://www.youtube.com/watch?v=S-VDVgCBy-M Shader minification for 4k - 64k intros (2023)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=xLhT06lwaig 4klang 101 - Basics (2019)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=Ir0vcmHkIm0 nstalling and trying out different synths for 4kb intros (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=9BqKH0XNN-g Size Restricted music isn't Rocketscience (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=wP__g_9FT4M Sound Design with 4klang, by Wayfinder (2015)]&lt;br /&gt;
&lt;br /&gt;
==== Articles ====&lt;br /&gt;
* [ftp://ftp.untergrund.net/users/thygrion/sosp.zip Music in 4 Kilobytes - Size Optimized Synthesizer Programming]&lt;br /&gt;
* [https://iquilezles.org/articles/function2009/function2009.pdf Behind Elevated]&lt;br /&gt;
* [https://in4k.github.io/html_articles/Amietia%20%E2%80%A2%20The%20Making%20Of%20Oscar's%20Chair.html Making of Oscar's chair]&lt;br /&gt;
* [https://www.codeslow.com/2020/07/writing-winning-4k-intro-in-rust.html Article about writing a 4k intro using Rust]&lt;br /&gt;
* [https://in4k.github.io/wiki/aulds-4k-synth Article about writing a softsynth]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	<entry>
		<id>http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1829</id>
		<title>4K Intro</title>
		<link rel="alternate" type="text/html" href="http://www.sizecoding.org/index.php?title=4K_Intro&amp;diff=1829"/>
				<updated>2025-11-03T23:38:19Z</updated>
		
		<summary type="html">&lt;p&gt;Superogue: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
This category is dedicated to modern 4K Intro development for [[Windows|Windows / Win32]], which consist of a small OpenGL/D3D/DX Framework, a softsynth and 1 or more pixelshaders. As such this won't be discussion legacy mesh techniques as few 4k intros make use of those techniques anymore.&lt;br /&gt;
&lt;br /&gt;
Most Windows 4K Intros will be setup using C, sometimes in combination with assembler, or in some cases pure assembler. In general writing everything in assembler should give you a little more freedom in pushing/popping your function arguments and register usage.&lt;br /&gt;
&lt;br /&gt;
Graphics are usualy done using OpenGL / GLSL or Direct3D/DX11.&lt;br /&gt;
&lt;br /&gt;
=== Tools ===&lt;br /&gt;
There are a couple of options for tools, but generally these tools are often used&lt;br /&gt;
* Visual Studio / Vscode / GCC Compiler &lt;br /&gt;
* Crinkler or other external packer for compression ( https://crinkler.net )&lt;br /&gt;
* Shader minifier ( https://github.com/laurentlb/Shader_Minifier )&lt;br /&gt;
* Optional / Alternatively: NASM Assembler ( https://nasm.us/ )&lt;br /&gt;
* Optional: Local/Online GLSL Shader editing environment (e.g. Shadertoy, Kodelife, bonzo, etc.)&lt;br /&gt;
* Optional: Timeline/Camera tooling&lt;br /&gt;
* Optional: gnuRocket for timing.&lt;br /&gt;
&lt;br /&gt;
== Intro design ==&lt;br /&gt;
When designing a 4k intro, it is best practice to consider each of the following aspects seperately:&lt;br /&gt;
&lt;br /&gt;
* How much size budget do you want to allocate to render pipeline, sound, scene building, (post)shading, progression?&lt;br /&gt;
* Abstract vs organic vs scene/world-building &lt;br /&gt;
* Single scene vs multiple scenes&lt;br /&gt;
* Ray-Intersections or Ray Marching&lt;br /&gt;
* What kind of softsynth to use, or writing your own&lt;br /&gt;
* Render pipeline - Single or multipass (post/audio)shaders.&lt;br /&gt;
* Scene, Camera and progression handling&lt;br /&gt;
* Text - Do you want to include text and if so: Are you using WindowsGlyphs texture or SDF&lt;br /&gt;
&lt;br /&gt;
=== Design pitfalls ===&lt;br /&gt;
Here are a few design pitfalls you should try to avoid if necessary.&lt;br /&gt;
&lt;br /&gt;
==== Undirected raymarch experiments ====&lt;br /&gt;
Wiggly domain repetition shadertoy experiments, with or without walking glows, might be sufficient for a shaderjam or shader-showdown, but usually make a sub-par 4k intro. Don't do it, even if it has the compofiller banner on the slide.&lt;br /&gt;
  &lt;br /&gt;
====  The Rebranded cornell box - Just a shiny sphere bro! ==== &lt;br /&gt;
Its great as a rendertest reference for your PBR / pathtracing tests, but it doesn't make a compelling intro.&lt;br /&gt;
The times you still see a reflective/pathtraced sphere and/or box with music mask as a 4k intro is staggering. &lt;br /&gt;
Sadly sceners still accept these rebranded cornell boxes as legit and even winning/cdc receiving intros, because shineys.&lt;br /&gt;
But my intuition says these will be looked upon like the countless early 2000s goa+bended sphers/torus intros that fail to stand the test of time.&lt;br /&gt;
&lt;br /&gt;
====  Shitty synths ==== &lt;br /&gt;
There are a few great intros out there that have great visuals but are ruined by glopawful synths or music. If you are not good at music yourself, find yourself a musician to work with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Size Budgeting ==&lt;br /&gt;
A general rule of thumb is to work above the target size for most of the development and work your way down when the production is closer to completion.&lt;br /&gt;
&lt;br /&gt;
There are many ways to split the same bytes, here are the top-5 4K Intros at Revision 2024 that have made wildly different choices.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Ranking !! Intro Title !! Progression / Storytelling !! Object complexity || Graphics Fidelity !! Sound !! Notes !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Drifting Shore || Low || Low || Very-High || Low || Ray-Intersection + Pathtracing || https://demozoo.org/productions/342196/&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Dubplate || Medium || Low || High || Very-High || SDF Text || https://demozoo.org/productions/342202/&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Return to nature || High || High || Low || Low || - || https://demozoo.org/productions/342200/&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Brainfiller || Low || Medium || High || High || GLSL Softsynth || https://demozoo.org/productions/342203/&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Once Upon A Time In A Datacenter || High || Very-High || Low || Low || Custom CPU synthcode || https://demozoo.org/productions/342199/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Graphics fidelity ====&lt;br /&gt;
TBA&lt;br /&gt;
&lt;br /&gt;
==== Music budget ====&lt;br /&gt;
Got a musician to work with you and deliver a great tune? Don't accept it right out of the gate and feel free to argue about possible optimisations that can be done to the tune that will not affect the end-result massively. This is done by all of the better-known 4k intro developers and a good musician will be open to discussion and aware of the different limitation and choices that have to be made when it comes to size budgeting.&lt;br /&gt;
&lt;br /&gt;
== Setting up your framework ==&lt;br /&gt;
A 4k framework / intro can be setup in either C or Assembler, or a combination of both.&lt;br /&gt;
You can either go with an existing framework (some of them are quite capable) or build your own taylored to your own needs.&lt;br /&gt;
Also remember that even though there are many more ways to save size than in for example a 1k intro, that every byte saved here is one you can spent / budget elsewhere.&lt;br /&gt;
&lt;br /&gt;
* The groundlevel basics of a framework are discussed on the 1K Intro wiki at http://www.sizecoding.org/wiki/1K_Intro&lt;br /&gt;
* From here you can setup your audiobuffer add a softsynth of choice, or write your own (either in GLSL or Software)&lt;br /&gt;
* Most likely you'll like to add a few more function imports to properly pass uniforms to your shader.&lt;br /&gt;
* Optionally: Add another render-pass by feeding the output of the main shader to a post-shading process. This adds a few more texture calls to the framework&lt;br /&gt;
* Optionally: Add an init pass where you prepare (glyph) textures and other buffers you'd like to feed into your main shader.&lt;br /&gt;
* Optionally: Hook up a Scene/Camera/Timing system during development&lt;br /&gt;
&lt;br /&gt;
== Graphics ==&lt;br /&gt;
Once you've budgeted and designed your intro, it is time to go to work. &lt;br /&gt;
&lt;br /&gt;
==== Prebuild your scene in an external tool ====&lt;br /&gt;
For convenience and turn-around time, its perfectly fine to use external online/offline tools like Shadertoy, Posh-Brolly, Kodelife, Bonzo or others to setup you main scene(s) / effects.&lt;br /&gt;
&lt;br /&gt;
==== Ray-Intersetions vs Raymarching ====&lt;br /&gt;
In theory ideally you'd like to have multi-sample, multiple bounces, highly flexible, highly accurate raymarching&lt;br /&gt;
But in practice this is as of year (2024) still impossible to do realtime on most systems, therefore a choice has to be made between exact interesctions of primitives / raytracing vs ray marching. What are the differences in usecases and what are their pros and cons:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Description !! Raymarching !! Ray-Intersection !! Examples&lt;br /&gt;
|-&lt;br /&gt;
| Domain-Repetition || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Fast Multi-Sample || No || Yes || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Twisting &amp;amp; Blending || Yes || No || TBA&lt;br /&gt;
|-&lt;br /&gt;
| Shape-Blending || Yes || ? || TBA&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Post processing: Don't miss the low-hanging fruit ====&lt;br /&gt;
Having a proper post processing step can greatly improve the overall visual quality of your intro. So in 4k space i would suggest a postshader pass at minimum, which depending on your size budget you can use for things like Vignetting, DOF, tone-mapping, anti-aliasing, chromatic abberation, etc. &lt;br /&gt;
&lt;br /&gt;
But even if your 4k intro doesn't have a seperate post-shader pass, adding a bit of in-shader vignetting / gamma correction / tone-mapping to your intro are relative easy/cheap ways to improve visual quality of your intro, so why leave those options off the table?&lt;br /&gt;
For inspiration, You can check out the article at Here is an article at https://30fps.net/pages/post-processing/ for a few things you can do to improve your visuals in post.&lt;br /&gt;
&lt;br /&gt;
== Sound ==&lt;br /&gt;
Here is an overview of various Synths / Music options.&lt;br /&gt;
Depending on the exact track, you are looking at approx 1k - 1.5k compressed for music for most 4k intros.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Synth !! Type !! Description !! Size overhead !! Link&lt;br /&gt;
|-&lt;br /&gt;
| 4klang || Subtractive || Most popular softsynth || Medium (1 note, 1 instrument at 620b) || https://github.com/gopher-atz/4klang&lt;br /&gt;
|-&lt;br /&gt;
| Sointu || Subtractive || 4klang fork with improvements || Medium (1 note, 1 instrument at 562b )|| https://github.com/vsariola/sointu/&lt;br /&gt;
|-&lt;br /&gt;
| Oidos || Additive || - || Medium (1 note, 1 instrument at 600b) || https://github.com/askeksa/Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Clinkster || FM || - || Medium (1 note, 1 instrument at 590b) || http://crinkler.net/Clinkster.zip&lt;br /&gt;
|-&lt;br /&gt;
| GLSL Softsynth || - || Write it yourself || Small/Medium (depends on usecase) || -&lt;br /&gt;
|-&lt;br /&gt;
| MIDI Player || MIDI || Using default Windows midi sounds || Small/Medium (depends on player/song complexity) || -&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
As a snapshot. Here is a list of intros from 2017 with the synth they used:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| Absolute Territory || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Waillee || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| final stage || Custom&lt;br /&gt;
|-&lt;br /&gt;
| Horizon Machine || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Unprogress || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Faraday Future || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Alive Here Now, Forever || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Destination Unknown || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| w a y f a r e r || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| HAL 4000 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Equilibrium || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| visit berlin || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| お花見 || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Gary Glitter || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Superfine || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Cycle Of Nature || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Oxano || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Those Who Leave || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Maintenance || Clinkster&lt;br /&gt;
|-&lt;br /&gt;
| Joia || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Back to the Roots || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| Dropletia || Oidos&lt;br /&gt;
|-&lt;br /&gt;
| crystalline lord || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| highrider || 4klang&lt;br /&gt;
|-&lt;br /&gt;
| Primordial Soup || Custom&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
Crinkler is the most commonly used compression at the moment for 4K intros. It maximizes compression by taking over the linking process, setting up the windows header for you and if needed re-arrange the different segments of the code.&lt;br /&gt;
&lt;br /&gt;
==== Crinkler reports ====&lt;br /&gt;
When using the &amp;lt;code&amp;gt;/REPORT:intro_report.html&amp;lt;/code&amp;gt; feature, crinkler will generate a report and heatmap for your intro binary.&lt;br /&gt;
This is helpful to see how well your (shader)code compresses and where you can maybe gain a few more bytes.&lt;br /&gt;
&lt;br /&gt;
==== Word about the resulting executable ====&lt;br /&gt;
Please note that when using crinkler in TINYHEADER mode, the resulting windows header will most likely trigger virus scanners / Microsoft Defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice  to include a (slightly larger) safe version too in the final archive.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
==== Frameworks ====&lt;br /&gt;
* [https://github.com/armak/Leviathan-2.0 Leviathan 2.0]&lt;br /&gt;
* [https://github.com/in4k/isystem1k4k IQ's 1k/4k frameworks]&lt;br /&gt;
* [https://github.com/psycholns/TinyDX11 Psycho's 1k/4k framework]&lt;br /&gt;
* [http://www.kameli.net/compofillerstudio/ Compofiller studio]&lt;br /&gt;
* [https://github.com/yosshin4004/minimal_gl Minimal gl framework]&lt;br /&gt;
* [https://github.com/Beluki/4kGL 4KGL framework]&lt;br /&gt;
&lt;br /&gt;
==== Raymarching ====&lt;br /&gt;
* [https://jamie-wong.com/2016/07/15/ray-marching-signed-distance-functions/ Introduction to Raymarching]&lt;br /&gt;
* [https://iquilezles.org/articles/distfunctions/ IQ's distance functions page]&lt;br /&gt;
* [https://mercury.sexy/hg_sdf/ Mercury's SDF toolbox]&lt;br /&gt;
&lt;br /&gt;
==== High Quality 4K intros for Windows ====&lt;br /&gt;
* [https://demozoo.org/productions/371094/ Hexer (2025)]&lt;br /&gt;
* [https://demozoo.org/productions/355449/ XO (2024)]&lt;br /&gt;
* [https://demozoo.org/productions/331908/ Architectural Shapeshifter (2023)]&lt;br /&gt;
* [https://demozoo.org/productions/311778/ Stahlbeton (2022)]&lt;br /&gt;
* [https://demozoo.org/productions/278629/ The Vanishing of Ashlar (2020)]&lt;br /&gt;
* [https://demozoo.org/productions/266556/ Eisenerz (2019)]&lt;br /&gt;
* [https://demozoo.org/productions/185233/ Oscar's Chair (2018)]&lt;br /&gt;
* [https://demozoo.org/productions/174689/ Unprogress (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/178895/ Waillee (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/170744/ Horizon Machine (2017)]&lt;br /&gt;
* [https://demozoo.org/productions/91680/ Neuron (2013)]&lt;br /&gt;
* [https://demozoo.org/productions/102/ Elevated (2009)]&lt;br /&gt;
* [https://demozoo.org/productions/4846/ Atrium (2008)]&lt;br /&gt;
&lt;br /&gt;
==== 4K intros for Windows with Sourcecode ====&lt;br /&gt;
* [https://github.com/friol/planetx Planet X (2025)]&lt;br /&gt;
* [https://github.com/vsariola/dipping-deep-dub-drop/tree/master Dipping deep dub drop (2025)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2024-08_4k-intro_olkiluoto_3-2-1 Olkiluoto 3-1-1 (2024)]&lt;br /&gt;
* [https://github.com/0b5vr/brainfiller Brainfiller (2024)]&lt;br /&gt;
* [https://github.com/TheNuSan/Lev4k/tree/DriftingShore Drifting Shore (2024)]&lt;br /&gt;
* [https://github.com/vsariola/every-datapoint Every Datapoint has a soul (2024)]&lt;br /&gt;
* [https://github.com/Krafpy/Island/tree/master/ Island (2024)] &lt;br /&gt;
* [https://github.com/LeStahL/ontrack-4k physics girl (2023)]&lt;br /&gt;
* [https://github.com/vsariola/fluxerator Fluxerator (2023)]&lt;br /&gt;
* [https://github.com/vsariola/adam Adam (2021)]&lt;br /&gt;
* [https://github.com/LeStahL/abstraction-confusion Abstraction Confusion (2021)]&lt;br /&gt;
* [https://github.com/faemiyah/faemiyah-demoscene_2019-08_4k-intro_region_de_magallanes Region de Magallanes (2019)]&lt;br /&gt;
* [https://github.com/w23/nwep nwep (2017)]&lt;br /&gt;
* [https://github.com/keensky/hal4000 Hall4000 (2017)]&lt;br /&gt;
* [https://github.com/in4k/rgba_tbc_elevated_source Elevated (2009)]&lt;br /&gt;
&lt;br /&gt;
==== Seminars ====&lt;br /&gt;
* [https://www.youtube.com/watch?v=S-VDVgCBy-M Shader minification for 4k - 64k intros (2023)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=xLhT06lwaig 4klang 101 - Basics (2019)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=Ir0vcmHkIm0 nstalling and trying out different synths for 4kb intros (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=9BqKH0XNN-g Size Restricted music isn't Rocketscience (2017)]&lt;br /&gt;
* [https://www.youtube.com/watch?v=wP__g_9FT4M Sound Design with 4klang, by Wayfinder (2015)]&lt;br /&gt;
&lt;br /&gt;
==== Articles ====&lt;br /&gt;
* [ftp://ftp.untergrund.net/users/thygrion/sosp.zip Music in 4 Kilobytes - Size Optimized Synthesizer Programming]&lt;br /&gt;
* [https://iquilezles.org/articles/function2009/function2009.pdf Behind Elevated]&lt;br /&gt;
* [https://in4k.github.io/html_articles/Amietia%20%E2%80%A2%20The%20Making%20Of%20Oscar's%20Chair.html Making of Oscar's chair]&lt;br /&gt;
* [https://www.codeslow.com/2020/07/writing-winning-4k-intro-in-rust.html Article about writing a 4k intro using Rust]&lt;br /&gt;
* [https://in4k.github.io/wiki/aulds-4k-synth Article about writing a softsynth]&lt;/div&gt;</summary>
		<author><name>Superogue</name></author>	</entry>

	</feed>