llvm-mos-sdk
c128.h
Go to the documentation of this file.
1 // Copyright 2023 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 
6 // Originally from cc65. Modified from original version.
7 
8 // clang-format off
9 
10 /*****************************************************************************/
11 /* */
12 /* c128.h */
13 /* */
14 /* C128 system specific definitions */
15 /* */
16 /* */
17 /* */
18 /* (C) 1998-2013, Ullrich von Bassewitz */
19 /* Roemerstrasse 52 */
20 /* D-70794 Filderstadt */
21 /* EMail: uz@cc65.org */
22 /* */
23 /* */
24 /* This software is provided 'as-is', without any expressed or implied */
25 /* warranty. In no event will the authors be held liable for any damages */
26 /* arising from the use of this software. */
27 /* */
28 /* Permission is granted to anyone to use this software for any purpose, */
29 /* including commercial applications, and to alter it and redistribute it */
30 /* freely, subject to the following restrictions: */
31 /* */
32 /* 1. The origin of this software must not be misrepresented; you must not */
33 /* claim that you wrote the original software. If you use this software */
34 /* in a product, an acknowledgment in the product documentation would be */
35 /* appreciated but is not required. */
36 /* 2. Altered source versions must be plainly marked as such, and must not */
37 /* be misrepresented as being the original software. */
38 /* 3. This notice may not be removed or altered from any source */
39 /* distribution. */
40 /* */
41 /*****************************************************************************/
42 
43 
44 
45 #ifndef _C128_H
46 #define _C128_H
47 
48 
49 
50 /* Check for errors */
51 #if !defined(__C128__)
52 # error This module may only be used when compiling for the C128!
53 #endif
54 
55 
56 
57 /* Additional key defines */
58 #define CH_F1 133
59 #define CH_F2 137
60 #define CH_F3 134
61 #define CH_F4 138
62 #define CH_F5 135
63 #define CH_F6 139
64 #define CH_F7 136
65 #define CH_F8 140
66 
67 /* Color defines */
68 #define COLOR_BLACK 0x00
69 #define COLOR_WHITE 0x01
70 #define COLOR_RED 0x02
71 #define COLOR_CYAN 0x03
72 #define COLOR_PURPLE 0x04
73 #define COLOR_GREEN 0x05
74 #define COLOR_BLUE 0x06
75 #define COLOR_YELLOW 0x07
76 #define COLOR_ORANGE 0x08
77 #define COLOR_BROWN 0x09
78 #define COLOR_LIGHTRED 0x0A
79 #define COLOR_GRAY1 0x0B
80 #define COLOR_GRAY2 0x0C
81 #define COLOR_LIGHTGREEN 0x0D
82 #define COLOR_LIGHTBLUE 0x0E
83 #define COLOR_GRAY3 0x0F
84 
85 /* Masks for joy_read */
86 #define JOY_UP_MASK 0x01
87 #define JOY_DOWN_MASK 0x02
88 #define JOY_LEFT_MASK 0x04
89 #define JOY_RIGHT_MASK 0x08
90 #define JOY_BTN_1_MASK 0x10
91 
92 /* Video mode defines */
93 #define VIDEOMODE_40x25 0x00
94 #define VIDEOMODE_80x25 0x80
95 #define VIDEOMODE_40COL VIDEOMODE_40x25
96 #define VIDEOMODE_80COL VIDEOMODE_80x25
97 
98 
99 
100 /* Define hardware */
101 #include <_vic2.h>
102 #define VIC (*(volatile struct __vic2*)0xD000)
103 
104 #include <_sid.h>
105 #define SID (*(volatile struct __sid*)0xD400)
106 
107 #include <_vdc.h>
108 #define VDC (*(volatile struct __vdc*)0xD600)
109 
110 #include <_6526.h>
111 #define CIA1 (*(volatile struct __6526*)0xDC00)
112 #define CIA2 (*(volatile struct __6526*)0xDD00)
113 
114 
115 
116 /* Define special memory areas */
117 #define COLOR_RAM ((volatile unsigned char*)0xD800)
118 
119 
120 
127 unsigned char videomode (unsigned char mode);
128 
132  __attribute__((noreturn))
133 void c64mode (void);
134 
139 void fast (void);
140 
144 void slow (void);
145 
151 unsigned char isfast (void);
152 
153 /* End of c128.h */
154 #endif
_sid.h
isfast
unsigned char isfast(void)
Check CPU clock mode.
fast
void fast(void)
Switch the CPU into 2MHz mode. Note: This will disable video when in 40 column mode.
_vdc.h
_6526.h
videomode
unsigned char videomode(unsigned char mode)
Set the video mode, return the old mode.
mode
const void uint16_t uint8_t mode
Definition: memory.h:58
_vic2.h
slow
void slow(void)
Switch the CPU into 1MHz mode.