[Coco] Help with some HiRes CoCo 3 MMU settings
Arthur Flexser
flexser at fiu.edu
Wed Dec 7 06:22:40 EST 2016
Looks like you store a value into $FF90 (INIT0) and immediately store a
different value in the same place. Was the second store supposed to be to
$FF91?
Art
On Tue, Dec 6, 2016 at 11:23 PM, Glen Hewlett <glen.hewlett at sympatico.ca>
wrote:
> Hi All,
>
> I’ve been fighting for days trying to figure out why the program I’ve
> written is crashing. I think it’s the MMU doing some bank switching in the
> background while my program is running.
>
> My program disables all the interrupts the sets up the graphic mode in my
> case a 256x225 2 colour screen. I’m trying to use blocks 0 ($0000 to
> $1fff) and block 1 ($2000 to $3fff) for my graphics output screen and
> variables. My program code is running at $4000 and the stack is at $7FFF.
>
> While testing my program with the MAME emulator in debug mode, my program
> shows some graphics on the screen and runs along for a about 10 seconds
> then blamo, it crashes. As far as I can tell the bank memory is coming
> into play somehow. With Mame’s debugger I can see the banks of memory have
> wiped out my graphics screen and my program and filled it all with a bunch
> of $CD values in my RAM. Does this sound familiar to anyone maybe you know
> what I’m missing or doing wrong that would cause such a thing to happen.
>
> I looked all over the internet to see if anyone has some example code for
> setting up graphics modes and the MMU in assembly. All I’ve been able to
> find is tons and tons of technical manuals that do a great job of
> explaining what all the values do, but there aren’t any real world examples
> that I could find. If someone has some nice code that they want to share
> that would be awesome…
>
> Below is the initializing code that I’ve written and plan to use over and
> over for future programs.
>
> Thanks for looking,
> Glen
>
> *****************************************************
> ** Used Labels *
> *****************************************************
>
> TEXT_SCREEN_START EQU $0400
> TEXT_SCREEN_END EQU $0600
>
> IRQ_Jump_position EQU $FEF7 * Store $7E which is the JMP
> opcode
> IRQ_Start_Address EQU $FEF8 * Store the address you want the
> IRQ to jumpt to at this address
> IRQ_POINT EQU $FEF7 * $FEF7 is the usual CoCo3
> SuperBasic IRQ value
>
> PIA0_Byte_0_KeyRw_Joy EQU $FF00
> PIA0_Byte_1_HSYNC EQU $FF01
> PIA0_Byte_2 EQU $FF02
> PIA0_Byte_3_VSYNC EQU $FF03
>
> PIA1_Byte_0_IRQ EQU $FF20
> PIA1_Byte_1_IRQ EQU $FF21
> PIA1_Byte_2 EQU $FF22
> PIA1_Byte_3_IRQ_Ct_Snd EQU $FF23
>
> INIT0_Register0 EQU $FF90
>
> INIT1_Register1 EQU $FF91
> IRQENR EQU $FF92
> FIRQENR EQU $FF93
>
> Timer_register_LSB EQU $FF95
> Timer_register_MSB EQU $FF94
>
> Video_Mode_Register EQU $FF98
> Vid_Res_Reg EQU $FF99
> Border_Register EQU $FF9A
> VidStart EQU $FF9D *
> Hor_Offset_Reg EQU $FF9F
>
> MMU_Reg_0 EQU $FFA0
> MMU_Reg_1 EQU $FFA1
> MMU_Reg_2 EQU $FFA2
> MMU_Reg_3 EQU $FFA3
> MMU_Reg_4 EQU $FFA4
>
> *Screen Colour Settings
> Palette_Start EQU $FFB0
> Palette_0 EQU $FFB0
> Palette_1 EQU $FFB1
> Palette_2 EQU $FFB2
> Palette_3 EQU $FFB3
> Palette_4 EQU $FFB4
> Palette_5 EQU $FFB5
> Palette_6 EQU $FFB6
> Palette_7 EQU $FFB7
> Palette_8 EQU $FFB8
> Palette_9 EQU $FFB9
> Palette_10 EQU $FFBA
> Palette_11 EQU $FFBB
> Palette_12 EQU $FFBC
> Palette_13 EQU $FFBD
> Palette_14 EQU $FFBE
> Palette_15 EQU $FFBF
>
> Regular_Speed EQU $FFD8
> High_Speed_Mode EQU $FFD9
> ROM_Mode_Enable EQU $FFDE
> RAM_Mode_Enable EQU $FFDF
>
> Screen_Start EQU $8000
> Border_Colour EQU $00 * 00 - Black
>
> *Stack_Space RMB $100 * Example for making some stack space
>
> ***********************************************************
> ORG $4000 * Start in low memory after Disk Basic
> usage
> START LDS #$7FFF * Start of program
> ***********************************************************
> System_EnableGraphics
> ORCC #$50 * disable interrupts
> LDA #%01001100 * Coco3, MMU on, IRQ disabled,
> FIRQ Disabled, DRAM constant, standard SCS 16K internal 16K external ROM
> STA INIT0_Register0
>
> LDA #%00100000
> STA INIT0_Register0 * Select MMU Task Register 0 which
> is $FFA0 - $FFA7
>
> LDA #%10000000 * graphics mode, Colour output, 60
> hz, max vertical res
> STA Video_Mode_Register
>
> ***********************************************************
> * Set Hires Screen Resolution and the number of Colours
> *
> * Bit Pattern Rows Displayed
> * x00xxxxx 192
> * x01xxxxx 200
> * x10xxxxx *zero/infinite lines on screen (undefined)
> * x11xxxxx 225
> * Bit Pattern Bytes/Row (Graphics)
> * xxx000xx 16
> * xxx001xx 20
> * xxx010xx 32
> * xxx011xx 40
> * xxx100xx 64
> * xxx101xx 80 320 4 Colours 01
> * xxx110xx 128
> * xxx111xx 160
> * Bit Pattern Colours Pixels/Byte
> * xxxxxx00 2 8
> * xxxxxx01 4 4
> * xxxxxxl0 16 2
> * xxxxxx11 Undefined Undefined
> ***********************************************************
> * Most Common used settings (Uncomment the one you want to use)
> * LDA #%00001000 * 256 x 192 x 2 Colours requires
> 6,144 bytes = $1800 RAM
> * LDA #%00101000 * 256 x 200 x 2 Colours requires
> 6,400 bytes = $1900 RAM
> LDA #%01101000 * 256 x 225 x 2 Colours requires
> 7,200 bytes = $1C20 RAM
> * LDA #%00010001 * 256 x 192 x 4 Colours requires
> 12,288 bytes = $3000 RAM
> * LDA #%00110001 * 256 x 200 x 4 Colours requires
> 12,800 bytes = $3200 RAM
> * LDA #%01110001 * 256 x 220 x 4 Colours requires
> 14,400 bytes = $3840 RAM
> * LDA #%00011010 * 256 x 192 x 16 Colours requires
> 24,576 bytes = $6000 RAM
> * LDA #%00111010 * 256 x 200 x 16 Colours requires
> 25,600 bytes = $6400 RAM
> * LDA #%01111010 * 256 x 225 x 16 Colours requires
> 28,800 bytes = $7080 RAM
> * LDA #%00001100 * 320 x 192 x 2 Colours requires
> 7,680 bytes = $1E00 RAM
> * LDA #%00101100 * 320 x 200 x 2 Colours requires
> 8,000 bytes = $1F40 RAM
> * LDA #%01101100 * 320 x 225 x 2 Colours requires
> 10,240 bytes = $2800 RAM
> * LDA #%00010101 * 320 x 192 x 4 Colours requires
> 15,360 bytes = $3C00 RAM
> * LDA #%00110101 * 320 x 200 x 4 Colours requires
> 16,000 bytes = $3E80 RAM
> * LDA #%01110101 * 320 x 225 x 4 Colours requires
> 18,000 bytes = $4650 RAM
> * LDA #%00011110 * 320 x 192 x 16 Colours requires
> 30,720 bytes = $7800 RAM
> * LDA #%00111110 * 320 x 200 x 16 Colours requires
> 32,00 bytes = $7D00 RAM
> * LDA #%01111110 * 320 x 225 x 16 Colours requires
> 36,000 bytes = $8CA0 RAM
> * LDA #%00010100 * 640 x 192 x 2 Colours requires
> 15,360 bytes = $3C00 RAM
> * LDA #%00110100 * 640 x 200 x 2 Colours requires
> 16,000 bytes = $3E80 RAM
> * LDA #%01110100 * 640 x 225 x 2 Colours requires
> 18,000 bytes = $4650 RAM
> * LDA #%00011101 * 640 x 192 x 4 Colours requires
> 30,720 bytes = $7800 RAM
> * LDA #%00111101 * 640 x 200 x 4 Colours requires
> 32,000 bytes = $7D00 RAM
> * LDA #%01111101 * 640 x 225 x 4 Colours requires
> 36,000 bytes = $8CA0 RAM
>
> STA Vid_Res_Reg
>
> ***********************************************************
> * Border settings
> LDA #Border_Colour *
> STA Border_Register *
>
> LDD #$E000 * Point video screen veiwer at
> $70000 (Hi-Res page start)
> STD VidStart * which is at $70000 / 8 = $E000
>
> * Load GIME pages $30 & $31 into CPU RAM $0000-$1FFF & $2000-$4000
> LDA #$38 * Start at Hi-Res page #1
> STA $FFA0
> LDA #$39
> STA $FFA1
>
> * My program here….
>
>
>
> Final END START * set exec address
>
> * end of file -
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
More information about the Coco
mailing list