1 1.1 tsutsui # 2 1.1 tsutsui # Copyright (c) 2022 Tetsuya Isaki. All rights reserved. 3 1.1 tsutsui # 4 1.1 tsutsui # Redistribution and use in source and binary forms, with or without 5 1.1 tsutsui # modification, are permitted provided that the following conditions 6 1.1 tsutsui # are met: 7 1.1 tsutsui # 1. Redistributions of source code must retain the above copyright 8 1.1 tsutsui # notice, this list of conditions and the following disclaimer. 9 1.1 tsutsui # 2. Redistributions in binary form must reproduce the above copyright 10 1.1 tsutsui # notice, this list of conditions and the following disclaimer in the 11 1.1 tsutsui # documentation and/or other materials provided with the distribution. 12 1.1 tsutsui # 13 1.1 tsutsui # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 1.1 tsutsui # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 1.1 tsutsui # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 1.1 tsutsui # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 1.1 tsutsui # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 18 1.1 tsutsui # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 1.1 tsutsui # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 20 1.1 tsutsui # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 1.1 tsutsui # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 1.1 tsutsui # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 1.1 tsutsui # SUCH DAMAGE. 24 1.1 tsutsui 25 1.1 tsutsui # usage: hexdump -Cv xplx.rom | awk -f cdump.awk > xplx.inc 26 1.1 tsutsui 27 1.1 tsutsui { 28 1.1 tsutsui split($0, array, " "); 29 1.1 tsutsui 30 1.1 tsutsui # array[1] is the first column (address). 31 1.1 tsutsui for (i = 0; i < 16; i++) { 32 1.1 tsutsui str = array[2 + i] 33 1.1 tsutsui if (str !~ "[[:xdigit:]]{2}") { 34 1.1 tsutsui break 35 1.1 tsutsui } 36 1.1 tsutsui 37 1.1 tsutsui if (i == 0) { 38 1.1 tsutsui # nop 39 1.1 tsutsui } else if (i == 8) { 40 1.1 tsutsui printf "\n" 41 1.1 tsutsui } else { 42 1.1 tsutsui printf " " 43 1.1 tsutsui } 44 1.1 tsutsui printf "0x%s,", str 45 1.1 tsutsui } 46 1.1 tsutsui 47 1.1 tsutsui if (i != 0) { 48 1.1 tsutsui printf "\n" 49 1.1 tsutsui } 50 1.1 tsutsui } 51