A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 143 lines 4.9 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Pacbox - a Pacman Emulator for Rockbox 11 * 12 * Based on PIE - Pacman Instructional Emulator 13 * 14 * Copyright (c) 1997-2003,2004 Alessandro Scotti 15 * http://www.ascotti.org/ 16 * 17 * This program is free software; you can redistribute it and/or 18 * modify it under the terms of the GNU General Public License 19 * as published by the Free Software Foundation; either version 2 20 * of the License, or (at your option) any later version. 21 * 22 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 23 * KIND, either express or implied. 24 * 25 ****************************************************************************/ 26 27#ifndef _HARDWARE_H 28#define _HARDWARE_H 29 30extern unsigned char ram_[20*1024]; // ROM (16K) and RAM (4K) 31extern unsigned char charset_rom_[4*1024]; // Character set ROM (4K) 32extern unsigned char spriteset_rom_[4*1024]; // Sprite set ROM (4K) 33extern unsigned char dirty_[1024]; 34extern unsigned char video_mem_[1024]; // Video memory (1K) 35extern unsigned char color_mem_[1024]; // Color memory (1K) 36extern unsigned char charmap_[256*8*8]; /* Character data for 256 8x8 characters */ 37extern unsigned char spritemap_[64*16*16]; /* Sprite data for 64 16x16 sprites */ 38extern unsigned char output_devices_; /* Output flip-flops set by the game program */ 39extern unsigned char interrupt_vector_; 40extern unsigned coin_counter_; 41extern unsigned char port1_; 42extern unsigned char port2_; 43extern unsigned char dip_switches_; 44 45/* Output flip-flops */ 46enum { 47 FlipScreen = 0x01, 48 PlayerOneLight = 0x02, 49 PlayerTwoLight = 0x04, 50 InterruptEnabled = 0x08, 51 SoundEnabled = 0x10, 52 CoinLockout = 0x20, 53 CoinMeter = 0x40, 54 AuxBoardEnabled = 0x80 55}; 56 57struct PacmanSprite 58{ 59 int mode; /** Display mode (normal or flipped) */ 60 int x; /** X coordinate */ 61 int y; /** Y coordinate */ 62 int n; /** Shape (from 0 to 63) */ 63 int color; /** Base color (0=not visible) */ 64}; 65 66/* Internal tables and structures for faster access to data */ 67extern struct PacmanSprite sprites_[8]; /* Sprites */ 68extern short vchar_to_i_[1024]; 69 70void writeByte(unsigned addr, unsigned char b); 71unsigned char readPort( unsigned port ); 72void writePort( unsigned addr, unsigned char b ); 73void setOutputFlipFlop( unsigned char bit, unsigned char value ); 74 75/* 76 For Z80 Environment: read a byte from high memory addresses (i.e. the 77 memory-mapped registers) 78*/ 79static inline unsigned char readByte( unsigned addr ) 80{ 81 addr &= 0xFFFF; 82 83 if (addr < sizeof(ram_)) 84 return ram_[addr]; 85 86 // Address is not in RAM, check to see if it's a memory mapped register 87 switch( addr & 0xFFC0 ) { 88 // IN0 89 case 0x5000: 90 // bit 0 : up 91 // bit 1 : left 92 // bit 2 : right 93 // bit 3 : down 94 // bit 4 : switch: advance to next level 95 // bit 5 : coin 1 96 // bit 6 : coin 2 97 // bit 7 : credit (same as coin but coin counter is not incremented) 98 return port1_; 99 // IN1 100 case 0x5040: 101 // bit 0 : up (2nd player) 102 // bit 1 : left (2nd player) 103 // bit 2 : right (2nd player) 104 // bit 3 : down (2nd player) 105 // bit 4 : switch: rack test -> 0x10=off, 0=on 106 // bit 5 : start 1 107 // bit 6 : start 2 108 // bit 7 : cabinet -> 0x80=upright, 0x00=table 109 return port2_; 110 // DSW1 111 case 0x5080: 112 // bits 0,1 : coinage -> 0=free play, 1=1 coin/play, 2=1 coin/2 play, 3=2 coin/1 play 113 // bits 2,3 : lives -> 0x0=1, 0x4=2, 0x8=3, 0xC=5 114 // bits 4,5 : bonus life -> 0=10000, 0x10=15000, 0x20=20000, 0x30=none 115 // bit 6 : jumper pad: difficulty -> 0x40=normal, 0=hard 116 // bit 7 : jumper pad: ghost name -> 0x80=normal, 0=alternate 117 return dip_switches_; 118 // Watchdog reset 119 case 0x50C0: 120 break; 121 } 122 123 return 0xFF; 124} 125 126/* Reads a 16 bit word from memory at the specified address. */ 127static inline unsigned readWord( unsigned addr ) { 128 addr &= 0xFFFF; 129 130 if (addr < (sizeof(ram_)-1)) { 131 return ram_[addr] | ((ram_[addr+1]) << 8); 132 } else { 133 return readByte(addr) | (((unsigned)readByte(addr+1)) << 8); 134 } 135} 136 137/* Writes a 16 bit word to memory at the specified address. */ 138static inline void writeWord( unsigned addr, unsigned value ) { 139 writeByte( addr, value & 0xFF ); 140 writeByte( addr+1, (value >> 8) & 0xFF ); 141} 142 143#endif