<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.amstrad-cpc.net/index.php?action=history&amp;feed=atom&amp;title=Programming%3ACrt0Cart</id>
	<title>Programming:Crt0Cart - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.amstrad-cpc.net/index.php?action=history&amp;feed=atom&amp;title=Programming%3ACrt0Cart"/>
	<link rel="alternate" type="text/html" href="https://wiki.amstrad-cpc.net/index.php?title=Programming:Crt0Cart&amp;action=history"/>
	<updated>2026-09-04T03:55:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.amstrad-cpc.net/index.php?title=Programming:Crt0Cart&amp;diff=120372&amp;oldid=prev</id>
		<title>Reidrac at 07:49, 4 June 2022</title>
		<link rel="alternate" type="text/html" href="https://wiki.amstrad-cpc.net/index.php?title=Programming:Crt0Cart&amp;diff=120372&amp;oldid=prev"/>
		<updated>2022-06-04T07:49:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:49, 4 June 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It should be easy to adapt to other assemblers (it is likely that you won&amp;#039;t need all the extra directives for the linker).&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It should be easy to adapt to other assemblers (it is likely that you won&amp;#039;t need all the extra directives for the linker).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;I think got most of it from Kevin Thacker&#039;s [https://cpctech.cpcwiki.de/ The Unofficial Amstrad WWW Resource], but I can&#039;t find the exact link now. Anyway, Kevin is awesome and you should thank him if you have the chance.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;I think &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;I &lt;/ins&gt;got most of it from Kevin Thacker&#039;s [https://cpctech.cpcwiki.de/ The Unofficial Amstrad WWW Resource], but I can&#039;t find the exact link now. Anyway, Kevin is awesome and you should thank him if you have the chance.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         .module crt0&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         .module crt0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Reidrac</name></author>
	</entry>
	<entry>
		<id>https://wiki.amstrad-cpc.net/index.php?title=Programming:Crt0Cart&amp;diff=120371&amp;oldid=prev</id>
		<title>Reidrac: CRT0 for SDCC and CPC+ CPR carts</title>
		<link rel="alternate" type="text/html" href="https://wiki.amstrad-cpc.net/index.php?title=Programming:Crt0Cart&amp;diff=120371&amp;oldid=prev"/>
		<updated>2022-06-04T07:42:58Z</updated>

		<summary type="html">&lt;p&gt;CRT0 for SDCC and CPC+ CPR carts&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is an example of crt0.asm to use with [http://sdcc.sourceforge.net/ SDCC] compiler.&lt;br /&gt;
&lt;br /&gt;
It should be easy to adapt to other assemblers (it is likely that you won&amp;#039;t need all the extra directives for the linker).&lt;br /&gt;
&lt;br /&gt;
I think got most of it from Kevin Thacker&amp;#039;s [https://cpctech.cpcwiki.de/ The Unofficial Amstrad WWW Resource], but I can&amp;#039;t find the exact link now. Anyway, Kevin is awesome and you should thank him if you have the chance.&lt;br /&gt;
&lt;br /&gt;
        .module crt0&lt;br /&gt;
        .globl _main&lt;br /&gt;
        .globl _main_init&lt;br /&gt;
        &lt;br /&gt;
        ;; user_isr_hook will be exported so you can get current value&lt;br /&gt;
        ;; from C if you need to (it is defined in USR_ISR_HOOK anyway)&lt;br /&gt;
        .globl _user_isr_hook&lt;br /&gt;
        &lt;br /&gt;
        ;; the address for the ISR will be in RAM&lt;br /&gt;
        ;; this address is safe is you use double buffer, if you don&amp;#039;t&lt;br /&gt;
        ;; use 0xc000 - 3 instead; the stack will be placed after this stack&lt;br /&gt;
        USER_ISR_HOOK = 0x8000 - 3&lt;br /&gt;
        &lt;br /&gt;
                .area	_HOME&lt;br /&gt;
                .area	_CODE&lt;br /&gt;
                .area	_DATA&lt;br /&gt;
                .area	_INITIALIZER&lt;br /&gt;
                .area	_BSEG&lt;br /&gt;
                .area   _BSS&lt;br /&gt;
                .area	_HEAP&lt;br /&gt;
        &lt;br /&gt;
                .area   _CODE&lt;br /&gt;
        &lt;br /&gt;
        _main_init::&lt;br /&gt;
                jp init_cart&lt;br /&gt;
        &lt;br /&gt;
                ;; magic! used to setup the CRCT&lt;br /&gt;
                .db 0x3f, 0x28, 0x2e, 0x8e, 0x26, 0x00, 0x19, 0x1e, 0x00, 0x07, 0x00, 0x00, 0x30, 0x00, 0xc0, 0x00&lt;br /&gt;
        end_crtc_data:&lt;br /&gt;
        &lt;br /&gt;
                .ds 37&lt;br /&gt;
                &lt;br /&gt;
                ;; jump to a memory address that is RAM and we can change to&lt;br /&gt;
                ;; set our ISR&lt;br /&gt;
                .db 0xc3&lt;br /&gt;
        _user_isr_hook::&lt;br /&gt;
                .dw USER_ISR_HOOK&lt;br /&gt;
        &lt;br /&gt;
        init_cart:&lt;br /&gt;
                di&lt;br /&gt;
        &lt;br /&gt;
                ;; lower ROM on, mode 0&lt;br /&gt;
                ld bc, #0x7f88&lt;br /&gt;
                out (c), c&lt;br /&gt;
        &lt;br /&gt;
                ;; init PPI&lt;br /&gt;
                ld bc, #0xf782&lt;br /&gt;
                out (c), c&lt;br /&gt;
        &lt;br /&gt;
                ld bc, #0xf400&lt;br /&gt;
                out (c), c&lt;br /&gt;
        &lt;br /&gt;
                ld bc, #0xf600&lt;br /&gt;
                out (c), c&lt;br /&gt;
        &lt;br /&gt;
                ;; RAM config&lt;br /&gt;
                ld bc, #0x7fc0&lt;br /&gt;
                out (c), c&lt;br /&gt;
        &lt;br /&gt;
                ;; setup CRTC (from 6128 ROM)&lt;br /&gt;
                ld hl, #end_crtc_data&lt;br /&gt;
                ld bc, #0xbc0f&lt;br /&gt;
        crtc_loop:&lt;br /&gt;
                out (c), c&lt;br /&gt;
                dec hl&lt;br /&gt;
                ld a, (hl)&lt;br /&gt;
                inc b&lt;br /&gt;
                out (c), a&lt;br /&gt;
                dec b&lt;br /&gt;
                dec c&lt;br /&gt;
                jp p, crtc_loop&lt;br /&gt;
        &lt;br /&gt;
                ;; set the stack&lt;br /&gt;
                ld sp, #USER_ISR_HOOK&lt;br /&gt;
        &lt;br /&gt;
                ;; dummy int handler&lt;br /&gt;
                im 1&lt;br /&gt;
                ld hl, #0xc9fb&lt;br /&gt;
                ld (USER_ISR_HOOK), hl&lt;br /&gt;
        &lt;br /&gt;
                ei&lt;br /&gt;
        &lt;br /&gt;
                call _main&lt;br /&gt;
        &lt;br /&gt;
        halt0:&lt;br /&gt;
                halt&lt;br /&gt;
                jr halt0&lt;br /&gt;
        &lt;br /&gt;
        .area _DATA&lt;/div&gt;</summary>
		<author><name>Reidrac</name></author>
	</entry>
</feed>