Deleted:
/trunk/fake437++.pc.in
/trunk/include/fake437/display.h
/trunk/include/fake437/display.hpp
/trunk/include/fake437/surface.hpp
/trunk/include/fake437.hpp
/trunk/src/libfake437++/display.cpp
/trunk/src/libfake437++/surface.cpp
Modified:
/trunk/Makefile.am
/trunk/configure.ac
/trunk/doc/Makefile.am
/trunk/doc/libfake437.texi
/trunk/examples/example.c
/trunk/examples/surface.c
/trunk/include/fake437/primitive.h
/trunk/include/fake437/surface.h
/trunk/include/fake437/types.h
/trunk/include/fake437.h
/trunk/src/libfake437/primitive.c
/trunk/src/libfake437/surface.c
=======================================
--- /trunk/fake437++.pc.in Sat Apr 18 18:20:56 2009
+++ /dev/null
@@ -1,13 +0,0 @@
-# @configure_input@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libfake437++
-Description: libfake437++ is a C++ wrapper around libfake437.
-Version: @PACKAGE_VERSION@
-URL: http://libfake437.googlecode.com
-Requires: sdl >= 1.2.11 fake437 >= @PACKAGE_VERSION@
-Libs: -L${libdir} -lfake437++
-Cflags: -I${includedir}
=======================================
--- /trunk/include/fake437/display.h Fri Jan 1 19:06:33 2010
+++ /dev/null
@@ -1,173 +0,0 @@
-/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
- *
- * This library is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- ** @node F437Display Operations
- ** @chapter F437Display Operations
- **
- ** The @code{F437Display} provides a layer-oriented interface to a
- ** @code{F437Surface}.
- **/
-
-#ifndef FAKE437_DISPLAY_H
-#define FAKE437_DISPLAY_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- ** @deftypefun F437DisplayLayer* f437_display_layer_new @
- ** (int @var{left}, @
- ** int @var{top}, @
- ** int @var{width}, @
- ** int @var{height})
- **
- ** @deftypefunx F437DisplayLayer* f437_display_layer_try_new @
- ** (int @var{left}, @
- ** int @var{top}, @
- ** int @var{width}, @
- ** int @var{height})
- **
- ** Create a F437DisplayLayer with an initial reference count of
- ** 1. @code{f437_display_layer_new} calls @code{abort()} on
- ** allocation failure, while @code{f437_display_layer_try_new} just
- ** returns @code{NULL}.
- **
- ** @end deftypefun
- **/
-F437DisplayLayer* f437_display_layer_new(int left, int top,
- int width, int height);
-F437DisplayLayer* f437_display_layer_try_new(int left, int top,
- int width, int height);
-
-/**
- ** @deftypefun F437DisplayLayer* f437_display_layer_ref @
- ** (F437DisplayLayer* @var{layer})
- **
- ** @deftypefunx void f437_display_layer_unref @
- ** (F437DisplayLayer* @var{layer})
- **
- ** Increment/decrement the reference count of a display
- ** layer. There's no funny business going on with borrowed references
- ** or anything - always unref a pointer just before it goes out of
- ** scope.
- **
- ** @end deftypefun
- **/
-F437DisplayLayer* f437_display_layer_ref(F437DisplayLayer* layer);
-void f437_display_layer_unref(F437DisplayLayer* layer);
-
-/**
- ** @deftypefun F437Display* f437_display_new @
- ** (SDL_Surface* @var{surface}, @
- ** const F437Font* @var{font})
- **
- ** @deftypefunx F437Display* f437_display_try_new @
- ** (SDL_Surface* @var{surface}, @
- ** const F437Font* @var{font})
- **
- ** @deftypefunx SDL_Surface* f437_display_free @
- ** (F437Display* @var{display})
- **
- ** Create and destroy @code{F437Display}s. The @code{SDL_Surface*}
- ** passed to @code{f437_display_new} will not be owned by the
- ** display. It will be returned by @code{f437_display_free}.
- **
- ** @end deftypefun
- **/
-F437Display* f437_display_new(SDL_Surface* surface,
- const F437Font* font);
-F437Display* f437_display_try_new(SDL_Surface* surface,
- const F437Font* font);
-SDL_Surface* f437_display_free(F437Display* display);
-
-/**
- ** @deftypefun void f437_display_insert_layer @
- ** (F437Display* @var{display}, @
- ** F437DisplayLayer* @var{layer}, @
- ** int @var{n})
- **
- ** @deftypefunx F437DisplayLayer* f437_display_get_layer @
- ** (F437Display* @var{display}, @
- ** int @var{n})
- **
- ** @deftypefunx void f437_display_remove_layer @
- ** (F437Display* @var{display}, @
- ** int @var{n})
- **
- ** Add/examine/remove a layer from a display. When inserting, the new
- ** layer is inserted just before layer @var{n}. For get/remove, layer
- ** @var{n} is returned/removed. For @code{f437_display_get_layer},
- ** unref the pointer when finished.
- **
- ** @end deftypefun
- **/
-void f437_display_insert_layer(F437Display* display, F437DisplayLayer*
layer,
- int n);
-F437DisplayLayer* f437_display_get_layer(F437Display* display, int n);
-void f437_display_remove_layer(F437Display* display, int n);
-
-/**
- ** @deftypefun void f437_display_swap_layers @
- ** (F437Display* @var{display}, @
- ** int @var{n}, @
- ** int @var{m})
- **
- ** Swap layers @var{n} and @var{m} in the display.
- **
- ** @end deftypefun
- **/
-void f437_display_swap_layers(F437Display* display, int n, int m);
-
-/**
- ** @deftypefun void f437_display_push_layer @
- ** (F437Display* @var{display}, @
- ** F437DisplayLayer* @var{layer})
- **
- ** @deftypefunx F437DisplayLayer* f437_display_peek_layer @
- ** (F437Display* @var{display})
- **
- ** @deftypefunx void f437_display_pop_layer @
- ** (F437Display* @var{display})
- **
- ** Treat the display as a stack of layers. For
- ** @code{f437_display_peek_layer}, be sure to unref the returned
- ** pointer when finished.
- **
- ** @end deftypefun
- **/
-void f437_display_push_layer(F437Display* display, F437DisplayLayer*
layer);
-F437DisplayLayer* f437_display_peek_layer(F437Display* display);
-void f437_display_pop_layer(F437Display* display);
-
-/**
- ** @deftypefun void f437_display_draw @
- ** (F437Display* @var{display})
- **
- ** Redraw the underlying surface based on @var{display}'s current
- ** contents.
- **
- ** @end deftypefun
- **/
-void f437_display_draw(F437Display* display);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
=======================================
--- /trunk/include/fake437/display.hpp Wed Jan 6 19:37:03 2010
+++ /dev/null
@@ -1,76 +0,0 @@
-/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
- *
- * This library is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef FAKE437_DISPLAY_HPP
-#define FAKE437_DISPLAY_HPP
-
-namespace fake437 {
- class DisplayLayer {
- friend class Display;
- public:
- DisplayLayer(int left, int top, int width, int height);
- /* Only shares the reference. */
- DisplayLayer(const DisplayLayer& other);
- /* Does not incrememnt the reference count, so implicit conversion
- from the result of Display::get_layer etc. doesn't generate
- spurious f437_display_layer_ref's. */
- DisplayLayer(F437DisplayLayer* layer);
- ~DisplayLayer(void);
- /* Only shares the reference. */
- DisplayLayer& operator =(const DisplayLayer& other);
- F437DisplayCell& get_cell(int x, int y);
- int get_left(void) const;
- int get_top(void) const;
- void set_left(int left);
- void set_top(int top);
- private:
- F437DisplayLayer* layer;
- };
-
- class Display {
- public:
- Display(SDL_Surface* surface, const F437Font* font);
- ~Display(void);
-
- void insert_layer(F437DisplayLayer* layer, int n);
- void insert_layer(DisplayLayer& layer, int n);
- F437DisplayLayer* get_layer(int n);
- void remove_layer(int n);
-
- void swap_layers(int n, int m);
-
- void push_layer(F437DisplayLayer* layer);
- void push_layer(DisplayLayer& layer);
- F437DisplayLayer* peek_layer(void);
- void pop_layer(void);
-
- void draw(void);
-
- SDL_Surface* get_surface(void);
-
- /* Width/height in characters. */
- int get_width(void) const;
- int get_height(void) const;
- private:
- F437Display *display;
- /* Disallow copy and assign. */
- Display(const Display&);
- void operator =(const Display&);
- };
-}
-
-#endif
=======================================
--- /trunk/include/fake437/surface.hpp Fri Jan 1 19:07:03 2010
+++ /dev/null
@@ -1,57 +0,0 @@
-/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
- *
- * This library is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef FAKE437_SURFACE_HPP
-#define FAKE437_SURFACE_HPP
-
-namespace fake437 {
- class Surface {
- public:
- Surface(SDL_Surface* surface, const F437Font* font);
- ~Surface(void);
- void put_char(int left, int top, int ch,
- const SDL_Color& fg, const SDL_Color& bg);
- void put_char(int left, int top, int ch, F437Color fg, F437Color bg);
-
- void put_rect(int left, int top, int width, int height, int ch,
- const SDL_Color& fg, const SDL_Color& bg);
- void put_rect(int left, int top, int width, int height, int ch,
- F437Color fg, F437Color bg);
-
- void put_string(int left, int top, const char* string,
- const SDL_Color& fg, const SDL_Color& bg);
- void put_string(int left, int top, const char* string,
- F437Color fg, F437Color bg);
- void put_string(int left, int top, const std::string& string,
- const SDL_Color& fg, const SDL_Color& bg);
- void put_string(int left, int top, const std::string& string,
- F437Color fg, F437Color bg);
-
- SDL_Surface* get_surface(void);
-
- /* Width/height in characters. */
- int get_width(void) const;
- int get_height(void) const;
- private:
- F437Surface* surface;
- /* Disallow copy and assign. */
- Surface(const Surface&);
- void operator =(const Surface&);
- };
-}
-
-#endif
=======================================
--- /trunk/include/fake437.hpp Fri Jan 1 19:06:33 2010
+++ /dev/null
@@ -1,27 +0,0 @@
-/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
- *
- * This library is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef FAKE437_HPP
-#define FAKE437_HPP
-
-#include <string>
-#include <fake437.h>
-
-#include <fake437/surface.hpp>
-#include <fake437/display.hpp>
-
-#endif
=======================================
--- /trunk/src/libfake437++/display.cpp Fri Jan 1 19:06:33 2010
+++ /dev/null
@@ -1,125 +0,0 @@
-/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
- *
- * This library is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include <assert.h>
-#include <SDL.h>
-#include "fake437.h"
-#include "fake437/display.hpp"
-
-namespace fake437 {
- DisplayLayer::DisplayLayer(int left, int top, int width, int height):
- layer(f437_display_layer_new(left, top, width, height)) {}
-
- DisplayLayer::DisplayLayer(const DisplayLayer& other):
- layer(f437_display_layer_ref(other.layer)) {}
-
- DisplayLayer::DisplayLayer(F437DisplayLayer* layer):
- layer(layer) {}
-
- DisplayLayer::~DisplayLayer(void) {
- f437_display_layer_unref(layer);
- }
-
- DisplayLayer& DisplayLayer::operator =(const DisplayLayer& other) {
- if (&other == this) return *this;
- f437_display_layer_unref(this->layer);
- this->layer = f437_display_layer_ref(other.layer);
- return *this;
- }
-
- F437DisplayCell& DisplayLayer::get_cell(int x, int y) {
- assert(x >= 0 && x < this->layer->width);
- assert(y >= 0 && y < this->layer->height);
- return this->layer->cells[y * this->layer->height + x];
- }
-
- int DisplayLayer::get_left(void) const {
- return this->layer->left;
- }
-
- int DisplayLayer::get_top(void) const {
- return this->layer->top;
- }
-
- void DisplayLayer::set_left(int left) {
- this->layer->left = left;
- }
-
- void DisplayLayer::set_top(int top) {
- this->layer->top = top;
- }
-
- Display::Display(SDL_Surface* surface, const F437Font* font):
- display(f437_display_new(surface, font)) {}
-
- Display::~Display(void) {
- f437_display_free(this->display);
- }
-
- void Display::insert_layer(F437DisplayLayer* layer, int n) {
- f437_display_insert_layer(this->display, layer, n);
- }
-
- void Display::insert_layer(DisplayLayer& layer, int n) {
- this->insert_layer(layer.layer, n);
- }
-
- F437DisplayLayer* Display::get_layer(int n) {
- return f437_display_get_layer(this->display, n);
- }
-
- void Display::remove_layer(int n) {
- f437_display_remove_layer(this->display, n);
- }
-
- void Display::swap_layers(int n, int m) {
- f437_display_swap_layers(this->display, n, m);
- }
-
- void Display::push_layer(F437DisplayLayer* layer) {
- f437_display_push_layer(this->display, layer);
- }
-
- void Display::push_layer(DisplayLayer& layer) {
- this->push_layer(layer.layer);
- }
-
- F437DisplayLayer* Display::peek_layer(void) {
- return f437_display_peek_layer(this->display);
- }
-
- void Display::pop_layer(void) {
- f437_display_pop_layer(this->display);
- }
-
- void Display::draw(void) {
- f437_display_draw(this->display);
- }
-
- int Display::get_width(void) const {
- return this->display->surface->width;
- }
-
- int Display::get_height(void) const {
- return this->display->surface->height;
- }
-
- SDL_Surface* Display::get_surface(void) {
- return this->display->surface->surface;
- }
-}
=======================================
--- /trunk/src/libfake437++/surface.cpp Fri Jan 1 19:06:33 2010
+++ /dev/null
@@ -1,88 +0,0 @@
-/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
- *
- * This library is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include <string>
-#include <SDL.h>
-#include "fake437.h"
-#include "fake437/surface.hpp"
-
-namespace fake437 {
- Surface::Surface(SDL_Surface* surface, const F437Font* font):
- surface(f437_surface_new(surface, font)) {}
-
- Surface::~Surface(void) {
- f437_surface_free(this->surface);
- }
-
- void Surface::put_char(int left, int top, int ch,
- const SDL_Color& fg, const SDL_Color& bg) {
- f437_surface_put_char(this->surface, left, top, ch, &fg, &bg);
- }
-
- void Surface::put_char(int left, int top, int ch,
- F437Color fg, F437Color bg) {
- f437_surface_put_char(this->surface, left, top, ch,
- f437_get_color(fg), f437_get_color(bg));
- }
-
- void Surface::put_rect(int left, int top, int width, int height, int ch,
- const SDL_Color& fg, const SDL_Color& bg) {
- f437_surface_put_rect(this->surface,
- left, top, width, height, ch, &fg, &bg);
- }
-
- void Surface::put_rect(int left, int top, int width, int height, int ch,
- F437Color fg, F437Color bg) {
- f437_surface_put_rect(this->surface, left, top, width, height, ch,
- f437_get_color(fg), f437_get_color(bg));
- }
-
- void Surface::put_string(int left, int top, const char* string,
- const SDL_Color& fg, const SDL_Color& bg) {
- f437_surface_put_string(this->surface, left, top, string, &fg, &bg);
- }
-
- void Surface::put_string(int left, int top, const char* string,
- F437Color fg, F437Color bg) {
- f437_surface_put_string(this->surface, left, top, string,
- f437_get_color(fg), f437_get_color(bg));
- }
-
- void Surface::put_string(int left, int top, const std::string& string,
- const SDL_Color& fg, const SDL_Color& bg) {
- f437_surface_put_string(this->surface, left, top, string.c_str(), &fg,
&bg);
- }
-
- void Surface::put_string(int left, int top, const std::string& string,
- F437Color fg, F437Color bg) {
- f437_surface_put_string(this->surface, left, top, string.c_str(),
- f437_get_color(fg), f437_get_color(bg));
- }
-
- SDL_Surface* Surface::get_surface(void) {
- return this->surface->surface;
- }
-
- int Surface::get_width(void) const {
- return this->surface->width;
- }
-
- int Surface::get_height(void) const {
- return this->surface->height;
- }
-}
=======================================
--- /trunk/Makefile.am Fri Jan 1 19:07:20 2010
+++ /trunk/Makefile.am Sat Oct 1 16:01:11 2011
@@ -13,53 +13,35 @@
libtool: $(LIBTOOL_DEPS)
$(SHELL) ./config.status --recheck
-pkgconfig_DATA = fake437.pc fake437++.pc
-
-include_HEADERS = include/fake437.h include/fake437.hpp
+pkgconfig_DATA = fake437.pc
+
+include_HEADERS = include/fake437.h
fake437dir = $(includedir)/fake437
fake437_HEADERS = \
- include/fake437/display.h \
- include/fake437/display.hpp \
include/fake437/primitive.h \
include/fake437/surface.h \
- include/fake437/surface.hpp \
include/fake437/types.h
-lib_LTLIBRARIES = libfake437.la libfake437++.la
+lib_LTLIBRARIES = libfake437.la
libfake437_la_SOURCES = \
- src/libfake437/display.c \
- src/libfake437/primitive.c \
- src/libfake437/surface.c \
- src/libfake437/fonts.h \
+ src/libfake437/font_8x14.c \
src/libfake437/font_8x8.c \
src/libfake437/font_8x8_thin.c \
- src/libfake437/font_8x14.c
-libfake437_la_LDFLAGS = $(SDL_L_FLAGS) -no-undefined -version-info 7:0:0
+ src/libfake437/fonts.h \
+ src/libfake437/primitive.c \
+ src/libfake437/surface.c
+libfake437_la_LDFLAGS = $(SDL_L_FLAGS) -no-undefined -version-info 8:0:0
libfake437_la_LIBADD = -lSDL
-libfake437___la_SOURCES = \
- src/libfake437++/display.cpp \
- src/libfake437++/surface.cpp
-libfake437___la_LDFLAGS = $(SDL_L_FLAGS) -no-undefined -version-info 3:0:0
-libfake437___la_LIBADD = libfake437.la
-
if ENABLE_EXAMPLES
noinst_PROGRAMS = \
- examples/display \
examples/example \
- examples/guy \
examples/surface
-examples_display_SOURCES = examples/display.c
-examples_display_LDADD = $(SDL_LIBS) libfake437.la
-
examples_example_SOURCES = examples/example.c
examples_example_LDADD = $(SDL_LIBS) libfake437.la
-examples_guy_SOURCES = examples/guy.cpp
-examples_guy_LDADD = $(SDL_LIBS) libfake437++.la
-
examples_surface_SOURCES = examples/surface.c
examples_surface_LDADD = $(SDL_LIBS) libfake437.la
endif
=======================================
--- /trunk/configure.ac Fri Jan 1 19:07:20 2010
+++ /trunk/configure.ac Sat Oct 1 16:01:11 2011
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.61])
-AC_INIT([libfake437], [0.6], [endga...@gmail.com])
+AC_INIT([libfake437], [0.7], [endga...@gmail.com])
AC_CONFIG_AUX_DIR([auxfiles])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER([config.h])
@@ -33,7 +33,6 @@
# Checks for programs.
AC_PROG_SED
AC_PROG_CC
-AC_PROG_CXX
# Checks for libraries.
PKG_CHECK_MODULES([SDL], [sdl], [:],
@@ -50,6 +49,6 @@
# Checks for library functions.
# Output.
-AC_CONFIG_FILES([fake437.pc fake437++.pc])
+AC_CONFIG_FILES([fake437.pc])
AC_CONFIG_FILES([Makefile doc/Makefile])
AC_OUTPUT
=======================================
--- /trunk/doc/Makefile.am Sat Oct 1 16:00:49 2011
+++ /trunk/doc/Makefile.am Sat Oct 1 16:01:11 2011
@@ -4,14 +4,12 @@
-e '/^ \*\* / { s/^ \*\* //; p; }' \
-e '/^ \*\*/ { s/^ \*\*//; p; }' $< > $@
-fake437-display.texi: ../include/fake437/display.h ; $(EXTRACT_TEXI)
fake437-primitive.texi: ../include/fake437/primitive.h; $(EXTRACT_TEXI)
fake437-surface.texi: ../include/fake437/surface.h ; $(EXTRACT_TEXI)
fake437-types.texi: ../include/fake437/types.h ; $(EXTRACT_TEXI)
info_TEXINFOS = libfake437.texi
libfake437_TEXINFOS = \
- fake437-display.texi \
fake437-primitive.texi \
fake437-surface.texi \
fake437-types.texi
=======================================
--- /trunk/doc/libfake437.texi Wed Dec 30 15:34:53 2009
+++ /trunk/doc/libfake437.texi Sat Oct 1 16:01:11 2011
@@ -19,7 +19,7 @@
This is the manual for libfake437 version @value{VERSION}, a library
for creating old-style character `graphics' in SDL.
-Copyright @copyright{} 2008, 2009 Jack Kelly.
+Copyright @copyright{} 2008, 2009, 2010, 2011 Jack Kelly.
@quotation
This manual is free documentation: it is available under the Creative
@@ -50,8 +50,6 @@
* Data Types:: Some useful constants and data structures.
* Primitive Operations:: Writing directly to a surface.
* F437Surface Operations:: Simplifying matters by using an F437Surface
struct.
-* F437Display Operations:: Abstract a F437Surface into a stack of layers.
-* CXX:: Wrapped version of the above for use from C++.
* Index:: Functions and constants defined by libfake437.
@end menu
@@ -69,21 +67,6 @@
@include fake437-types.texi
@include fake437-primitive.texi
@include fake437-surface.texi
-@include fake437-display.texi
-
-@node CXX
-@chapter CXX
-
-A C++ wrapper for @code{F437Surface} is available. The wrapper is quite
-straightforward. @code{F437Surface} is wrapped by a class
-@code{fake437::Surface}. Its constructor takes the same parameters as
-@code{f437_surface_new} and instance methods just pass their arguments
-straight through to the relevant f437_surface functions. Include
-@code{fake437.hpp} instead of @code{fake437.h}. Have a look at
-@code{fake437/surface.hpp}, as the various @code{put_} methods are
-overloaded to accept @code{F437Color} and @code{const SDL_Color&}
-parameters. @code{fake437::Surface::put_string} is overloaded for both
-@code{const char*} and @code{const std::string&} parameters.
@node Index
@unnumbered Index
=======================================
--- /trunk/examples/example.c Sun Dec 27 18:47:18 2009
+++ /trunk/examples/example.c Sat Oct 1 16:01:11 2011
@@ -13,28 +13,20 @@
int x;
int y;
int done = 0;
- const F437Font* font = f437_get_font(F437_FONT_8x8_THIN);
+ const F437Font* font = f437_get_font(F437_FONT_8x14);
+ const SDL_Color* fg = f437_get_color(F437_COLOR_BWHITE);
+ const SDL_Color* bg = f437_get_color(F437_COLOR_BLACK);
(void)argc;
(void)argv;
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(F437_DEFAULT_WIDTH * font->char_width,
F437_DEFAULT_HEIGHT * font->char_height, 0, 0);
- f437_put_rect(screen, font,
- 0, 0, F437_DEFAULT_WIDTH, F437_DEFAULT_HEIGHT, 176,
- f437_get_color(F437_COLOR_BBLUE),
- f437_get_color(F437_COLOR_CYAN));
- f437_put_string(screen, font, 0, 0,
- "0123456789012345678901234567890123456789"
- "0123456789012345678901234567890123456789",
- f437_get_color(F437_COLOR_BRED),
- f437_get_color(F437_COLOR_BBLACK));
- for (y = 0 ; y < 16 ; y++) {
- for (x = 0 ; x < 16 ; x++) {
- f437_put_char(screen, font,
- x * font->char_width, (y + 1) * font->char_height,
y*16+x,
- f437_get_color(F437_COLOR_BWHITE),
- f437_get_color(F437_COLOR_BLACK));
+ for (y = 0; y < 16; y++) {
+ for (x = 0; x < 16; x++) {
+ f437_putc(screen, font,
+ x * font->char_width, y * font->char_height, 1,
+ y*16+x, fg, bg);
}
}
=======================================
--- /trunk/examples/surface.c Sun Dec 27 18:47:18 2009
+++ /trunk/examples/surface.c Sat Oct 1 16:01:11 2011
@@ -22,31 +22,40 @@
screen = SDL_SetVideoMode(F437_DEFAULT_WIDTH * font->char_width,
F437_DEFAULT_HEIGHT * font->char_height, 0, 0);
- f437 = f437_surface_new(screen, font);
- f437_surface_put_rect(f437, 0, 0,
- F437_DEFAULT_WIDTH, F437_DEFAULT_HEIGHT, 178,
- f437_get_color(F437_COLOR_BBLUE),
- f437_get_color(F437_COLOR_CYAN));
- f437_surface_put_string(f437, 0, 0,
- "0123456789012345678901234567890123456789"
- "0123456789012345678901234567890123456789",
- f437_get_color(F437_COLOR_BRED),
- f437_get_color(F437_COLOR_BBLACK));
+ f437 = f437_surface_new(screen, font, 1);
+ f437_surface_fg(f437, f437_get_color(F437_COLOR_BBLUE));
+ f437_surface_bg(f437, f437_get_color(F437_COLOR_CYAN));
+ for (x = 0; x < f437->width; x++) {
+ for (y = 0; y < f437->height; y++) {
+ f437_surface_putc(f437, 178);
+ }
+ }
+
+ f437_surface_fg(f437, f437_get_color(F437_COLOR_BRED));
+ f437_surface_bg(f437, f437_get_color(F437_COLOR_BBLACK));
+ f437_surface_goto_xy(f437, 0, 0);
+ f437_surface_puts(f437,
+ "0123456789012345678901234567890123456789"
+ "0123456789012345678901234567890123456789");
+ f437_surface_fg(f437, f437_get_color(F437_COLOR_BWHITE));
+ f437_surface_bg(f437, f437_get_color(F437_COLOR_BLACK));
for (y = 0 ; y < 16 ; y++) {
+ f437_surface_goto_xy(f437, 0, y + 1);
for (x = 0 ; x < 16 ; x++) {
- f437_surface_put_char(f437, x, y + 1, y*16+x,
- f437_get_color(F437_COLOR_BWHITE),
- f437_get_color(F437_COLOR_BLACK));
+ f437_surface_putc(f437, y*16+x);
}
}
- f437_surface_put_string(f437, 0, 17, "Transparent is a color too!",
- f437_get_color(F437_COLOR_BGREEN),
- f437_get_color(F437_COLOR_BLUE));
- for (i = 0 ; i < 27 ; i++) {
- f437_surface_put_char(f437, i, 17, 1,
- f437_get_color(F437_COLOR_BLACK),
- f437_get_color(F437_COLOR_TRANSPARENT));
- }
+
+ f437_surface_goto_xy(f437, 0, 17);
+ f437_surface_fg(f437, f437_get_color(F437_COLOR_BGREEN));
+ f437_surface_bg(f437, f437_get_color(F437_COLOR_BLUE));
+ f437_surface_puts(f437, "Transparent is a color too!");
+
+ f437_surface_goto_xy(f437, 0, 17);
+ f437_surface_fg(f437, f437_get_color(F437_COLOR_BLACK));
+ f437_surface_bg(f437, NULL);
+ for (i = 0 ; i < 27 ; i++) f437_surface_putc(f437, 1);
+
SDL_Flip(screen);
while (!done) {
while (SDL_PollEvent(&ev)) {
=======================================
--- /trunk/include/fake437/primitive.h Fri Jan 1 19:05:51 2010
+++ /trunk/include/fake437/primitive.h Sat Oct 1 16:01:11 2011
@@ -1,5 +1,5 @@
/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
+ * Copyright (C) 2008, 2009, 2010, 2011 Jack Kelly <endga...@gmail.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -52,73 +52,29 @@
const F437Font* f437_get_font(F437FontName name);
/**
- ** @deftypefun void f437_put_char @
+ ** @deftypefun void f437_putc @
** (SDL_Surface* @var{surface}, @
** const F437Font* @var{font}, @
** int @var{x}, @
** int @var{y}, @
+ ** int @var{scale}, @
** int @var{ch}, @
** const SDL_Color* @var{fg}, @
** const SDL_Color* @var{bg})
**
- ** @code{f437_put_char} draws the character whose code is @var{ch} on
+ ** @code{f437_putc} draws the character whose code is @var{ch} on
** @var{surface} using @var{font}. @var{x} and @var{y} define an
- ** offset on the surface in pixels. @var{fg} and @var{bg} are the
- ** foreground and background colors. If @code{NULL} is passed as
+ ** offset on the surface in pixels. @var{scale} is an integer
+ ** multiplier for the size of the glyph. @var{fg} and @var{bg} are
+ ** the foreground and background colors. If @code{NULL} is passed as
** either @var{fg} or @var{bg}, foreground or background pixels will
** not be drawn, respectively.
**
** @end deftypefun
**/
-void f437_put_char(SDL_Surface* surface, const F437Font* font,
- int x, int y, int ch,
- const SDL_Color* fg, const SDL_Color* bg);
-
-/**
- ** @deftypefun void f437_put_rect @
- ** (SDL_Surface* @var{surface}, @
- ** const F437Font* @var{font}, @
- ** int @var{x}, @
- ** int @var{y}, @
- ** int @var{width}, @
- ** int @var{height}, @
- ** int @var{ch}, @
- ** const SDL_Color* @var{fg}, @
- ** const SDL_Color* @var{bg})
- **
- ** @code{f437_put_rect} draws a rectangle using the character with
- ** code @var{ch} on @var{surface}, with font @var{font}. @var{x} and
- ** @var{y} are pixel offsets. @var{width} and @var{height} define the
- ** width and height of the rectangle in characters. @var{fg} and
- ** @var{bg} are the foreground and background colors.
- **
- ** @end deftypefun
- **/
-void f437_put_rect(SDL_Surface* surface, const F437Font* font,
- int x, int y, int width, int height,
- int ch, const SDL_Color* fg, const SDL_Color* bg);
-
-/**
- ** @deftypefun void f437_put_string @
- ** (SDL_Surface* @var{surface}, @
- ** const F437Font* @var{font}, @
- ** int @var{x}, @
- ** int @var{y}, @
- ** const char* @var{string}, @
- ** const SDL_Color* @var{fg}, @
- ** const SDL_Color* @var{bg})
- **
- ** @code{f437_put_string} writes a null-terminated string pointed to
- ** by @var{string} to @var{surface} using @var{font}. As with
- ** @code{f437_put_char}, @var{x} and @var{y} are offsets in pixels
- ** and @var{fg} and @var{bg} are the foreground and background colors
- ** to use.
- **
- ** @end deftypefun
- **/
-void f437_put_string(SDL_Surface* surface, const F437Font* font,
- int x, int y, const char* string,
- const SDL_Color* fg, const SDL_Color* bg);
+void f437_putc(SDL_Surface* surface, const F437Font* font,
+ int x, int y, int scale, int ch,
+ const SDL_Color* fg, const SDL_Color* bg);
#ifdef __cplusplus
}
=======================================
--- /trunk/include/fake437/surface.h Fri Jan 1 19:05:51 2010
+++ /trunk/include/fake437/surface.h Sat Oct 1 16:01:11 2011
@@ -1,5 +1,5 @@
/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
+ * Copyright (C) 2008, 2009, 2010, 2011 Jack Kelly <endga...@gmail.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -19,8 +19,8 @@
** @node F437Surface Operations
** @chapter F437Surface Operations
**
- ** The @code{F437Surface} allows simplified writing of large numbers
- ** of characters to an @code{SDL_Surface}.
+ ** A @code{F437Surface} wraps a @code{SDL_Surface*}, and is passed as
+ ** an argument to all drawing calls.
**/
#ifndef FAKE437_SURFACE_H
@@ -33,7 +33,8 @@
/**
** @deftypefun F437Surface* f437_surface_new @
** (SDL_Surface* @var{surface}, @
- ** const F437Font* @var{font})
+ ** const F437Font* @var{font}, @
+ ** int @var{scale})
**
** Creates a @code{F437Surface} that is centred within @var{surface}
** and is as wide and as tall as possible while still able to fit
@@ -41,24 +42,39 @@
** @code{f437_surface_free} when no longer needed. An
** @code{F437Surface} assumes no ownership of any pointers it comes
** in contact with, and @var{surface} and @var{font} must have a
- ** longer lifespan than the returned @code{F437Surface*}. This
- ** function calls @code{abort} if there is an allocation failure.
+ ** longer lifespan than the returned @code{F437Surface*}.
+ **
+ ** A surface has a foreground and background colour, which are used
+ ** when printing. These are initially set to @code{NULL}
+ ** (transparent). The surface also has an insertion point, which
+ ** starts at the top-left corner.
+ **
+ ** @var{scale} is an integer multiplier for the font: an 8*14 font
+ ** with scale 2 will draw 16*28 glyphs.
+ **
+ ** This function calls @code{abort} if there is an allocation
+ ** failure.
**
** @end deftypefun
**/
-F437Surface* f437_surface_new(SDL_Surface* surface, const F437Font* font);
+F437Surface* f437_surface_new(SDL_Surface* surface,
+ const F437Font* font,
+ int scale);
/**
** @deftypefun F437Surface* f437_surface_try_new @
** (SDL_Surface* @var{surface}, @
- ** const F437Font* @var{font})
+ ** const F437Font* @var{font}, @
+ ** int @var{scale})
**
** As @code{f437_surface_new}, but returns @code{NULL} instead of
** aborting on allocation failure.
**
** @end deftypefun
**/
-F437Surface* f437_surface_try_new(SDL_Surface* surface, const F437Font*
font);
+F437Surface* f437_surface_try_new(SDL_Surface* surface,
+ const F437Font* font,
+ int scale);
/**
** @deftypefun SDL_Surface* f437_surface_free @
@@ -73,46 +89,89 @@
SDL_Surface* f437_surface_free(F437Surface* surface);
/**
- ** @deftypefun void f437_surface_put_char @
- ** (F437Surface* @var{surface}, @
- ** int @var{left}, @
- ** int @var{top}, @
- ** int @var{ch}, @
- ** const SDL_Color* @var{fg}, @
- ** const SDL_Color* @var{bg})
+ ** @deftypefun void f437_surface_putc @
+ ** (F437Surface* @var{surface}, @
+ ** int @var{ch})
**
- ** @deftypefunx void f437_surface_put_rect @
- ** (F437Surface* @var{surface}, @
- ** int @var{left}, @
- ** int @var{top}, @
- ** int @var{width}, @
- ** int @var{height}, @
- ** int @var{ch}, @
- ** const SDL_Color* @var{fg}, @
- ** const SDL_Color* @var{bg})
+ ** @deftypefunx void f437_surface_puts @
+ ** (F437Surface* @var{surface}, @
+ ** const char* @var{str})
**
- ** @deftypefunx void f437_surface_put_string @
- ** (F437Surface* @var{surface}, @
- ** int @var{left}, @
- ** int @var{top}, @
- ** const char* @var{string}, @
- ** const SDL_Color* @var{fg}, @
+ ** @deftypefunx void f437_surface_printf @
+ ** (F437Surface* @var{surface}, @
+ ** const char* @var{format}, @
+ ** ...)
+ **
+ ** @deftypefunx void f437_surface_nprintf @
+ ** (F437Surface* @var{surface}, @
+ ** int @var{n}, @
+ ** const char* @var{format}, @
+ ** ...)
+ **
+ ** @deftypefunx void f437_surface_vprintf @
+ ** (F437Surface* @var{surface}, @
+ ** const char* @var{format}, @
+ ** va_list @var{args})
+ **
+ ** @deftypefunx void f437_surface_vnprintf @
+ ** (F437Surface* @var{surface}, @
+ ** int @var{n}, @
+ ** const char* @var{format}, @
+ ** va_list @var{args})
+ **
+ ** Write a character, string or formatted string to the
+ ** surface. @code{f437_surface_nprintf} places an upper bound on the
+ ** number of characters written. Because code page 437 defines
+ ** various dingbats for the low characters, characters like
+ ** @code{'\n'} will not behave as they would when writing to a
+ ** terminal.
+ **
+ ** Printing automatically wraps left-to-right, top-to-bottom, and
+ ** will wrap around the whole screen.
+ **
+ ** @end deftypefun
+ **/
+
+void f437_surface_putc(F437Surface* surface, int ch);
+void f437_surface_puts(F437Surface* surface, const char* str);
+// TODO: write own version of G_GNUC_PRINTF(2,3) and use
+void f437_surface_printf(F437Surface* surface, const char* format, ...);
+void f437_surface_nprintf(F437Surface* surface, int n, const char*
format, ...);
+void f437_surface_vprintf(F437Surface* surface,
+ const char* format,
+ va_list args);
+void f437_surface_vnprintf(F437Surface* surface,
+ int n,
+ const char* format,
+ va_list args);
+/**
+ ** @deftypefun void f437_surface_fg @
+ ** (F437Surface* @var{surface}, @
+ ** const SDL_Color* @var{fg})
+ **
+ ** @deftypefunx void f437_surface_bg @
+ ** (F437Surface* @var{surface}, @
** const SDL_Color* @var{bg})
**
- ** These functions are similar to their counterparts in
- ** @ref{Primitive Operations}, except that @var{left} and @var{top}
- ** define offsets in characters instead of pixels.
+ ** Change the foreground/background colour of characters printed to
+ ** the surface.
**
** @end deftypefun
**/
-void f437_surface_put_char(F437Surface* surface, int left, int top, int ch,
- const SDL_Color* fg, const SDL_Color* bg);
-void f437_surface_put_rect(F437Surface* surface, int left, int top,
- int width, int height, int ch,
- const SDL_Color* fg, const SDL_Color* bg);
-void f437_surface_put_string(F437Surface* surface, int left, int top,
- const char* string,
- const SDL_Color* fg, const SDL_Color* bg);
+void f437_surface_fg(F437Surface* surface, const SDL_Color* fg);
+void f437_surface_bg(F437Surface* surface, const SDL_Color* bg);
+
+/**
+ ** @deftypefun void f437_surface_goto_xy @
+ ** (F437Surface* @var{surface}, @
+ ** int @var{x}, @
+ ** int @var{y})
+ **
+ ** Move the insertion point of the surface.
+ **
+ ** @end deftypefun
+ **/
+void f437_surface_goto_xy(F437Surface* surface, int x, int y);
#ifdef __cplusplus
}
=======================================
--- /trunk/include/fake437/types.h Fri Jan 1 19:07:20 2010
+++ /trunk/include/fake437/types.h Sat Oct 1 16:01:11 2011
@@ -1,5 +1,5 @@
/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
+ * Copyright (C) 2008, 2009, 2010, 2011 Jack Kelly <endga...@gmail.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -159,133 +159,68 @@
**
** A @code{F437Surface} encapsulates a @code{SDL_Surface} to provide
** a character-oriented interface, instead of a pixel-oriented
- ** one. @var{left} and @var{top} are pixel offsets into
- ** @var{surface}, while @var{width} and @var{height} specify the
- ** width and height of the @code{F437Surface} in characters. Clients
- ** should only ever read from the struct's fields, but never write to
- ** them. Use the supplied API instead.
+ ** one. Clients should only ever read from the struct's fields, but
+ ** never write to them. Use the supplied API instead.
**
** @deftypeivar F437Surface SDL_Surface* surface
+ ** The surface to be written upon.
** @end deftypeivar
**
** @deftypeivar F437Surface {const F437Font*} font
+ ** The font to be used when writing.
** @end deftypeivar
**
+ ** @deftypeivar F437Surface int scale
+ ** An integer multiplier on the size of the glyphs.
+ ** @end deftypeivar
+ **
** @deftypeivar F437Surface int left
+ ** Horizontal offset in pixels.
** @end deftypeivar
**
** @deftypeivar F437Surface int top
+ ** Vertical offset in pixels.
** @end deftypeivar
**
** @deftypeivar F437Surface int width
+ ** Width in characters.
** @end deftypeivar
**
** @deftypeivar F437Surface int height
+ ** Height in characters.
** @end deftypeivar
**
- ** @end deftp
- **/
-typedef struct {
- SDL_Surface* surface; /* not owned */
- const F437Font* font; /* not owned */
- int left;
- int top;
- int width;
- int height;
-} F437Surface;
-
-/**
- ** @deftp{Data Type} F437DisplayCell
- **
- ** A @code{F437DisplayCell} represents a cell in a
- ** @code{F437DisplayLayer}. It stores the character to display along
- ** with its foreground and background colours.
- **
- ** @deftypeivar F437DisplayCell F437Color fg
+ ** @deftypeivar F437Surface int cursor_x
+ ** X position of the insertion point.
** @end deftypeivar
**
- ** @deftypeivar F437DisplayCell F437Color bg
+ ** @deftypeivar F437Surface int cursor_y
+ ** Y position of the insertion point.
** @end deftypeivar
**
- ** @deftypeivar F437DisplayCell Uint8 ch
+ ** @deftypeivar F437Surface {const SDL_Color*} fg
+ ** Foreground colour.
** @end deftypeivar
**
- ** @end deftp
- **/
-typedef struct {
- F437Color fg;
- F437Color bg;
- Uint8 ch;
-} F437DisplayCell;
-
-/**
- ** @deftp{Data Type} F437DisplayLayer
- **
- ** A @code{F437DisplayLayer} is a collection of
- ** @code{F437DisplayCell}s of a certain width and height. The layer
- ** as a whole is drawn at a left and top offset relative to the
- ** top-left corner of the enclosing @code{F437Display}. @var{cells}
- ** is a @var{width}*@var{height} array of @code{F437DisplayCell}
- ** which is populated with graphical data. Accessing @code{left},
- ** @code{top} and the contents of @code{cells} is necessary and
- ** expected, but don't manually change @code{refcount}, @code{width}
- ** or @code{height}.
- **
- ** @deftypeivar F437DisplayLayer int refcount
+ ** @deftypeivar F437Surface {const SDL_Color*} bg
+ ** Background colour.
** @end deftypeivar
**
- ** @deftypeivar F437DisplayLayer int left
- ** @end deftypeivar
- **
- ** @deftypeivar F437DisplayLayer int top
- ** @end deftypeivar
- **
- ** @deftypeivar F437DisplayLayer int width
- ** @end deftypeivar
- **
- ** @deftypeivar F437DisplayLayer int height
- ** @end deftypeivar
- **
- ** @deftypeivar F437DisplayLayer F437DisplayCell* cells
- ** @end deftypeivar
- **
** @end deftp
**/
typedef struct {
- int refcount;
+ SDL_Surface* surface; /* not owned */
+ const F437Font* font; /* not owned */
+ int scale;
int left;
int top;
int width;
int height;
- F437DisplayCell* cells; /* owned */
-} F437DisplayLayer;
-
-/**
- ** @deftp{Data Type} F437Display
- **
- ** A @code{F437Display} abstracts a @code{F437Surface}, to provide
- ** an interface based around a tower of layers.
- **
- ** @deftypeivar F437Display F437Surface* surface
- ** @end deftypeivar
- **
- ** @deftypeivar F437Display int size
- ** @end deftypeivar
- **
- ** @deftypeivar F437Display int allocated_size
- ** @end deftypeivar
- **
- ** @deftypeivar F437Display F437DisplayLayer* layers
- ** @end deftypeivar
- **
- ** @end deftp
- **/
-typedef struct {
- F437Surface* surface; /* owned */
- int size; /* number of layers */
- int allocated_size; /* number of layers that can fit before reallocation
*/
- F437DisplayLayer** layers; /* owned */
-} F437Display;
+ int cursor_x;
+ int cursor_y;
+ const SDL_Color* fg;
+ const SDL_Color* bg;
+} F437Surface;
#ifdef __cplusplus
}
=======================================
--- /trunk/include/fake437.h Fri Jan 1 19:05:51 2010
+++ /trunk/include/fake437.h Sat Oct 1 16:01:11 2011
@@ -1,5 +1,5 @@
/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
+ * Copyright (C) 2008, 2009, 2010, 2011 Jack Kelly <endga...@gmail.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -18,11 +18,11 @@
#ifndef FAKE437_H
#define FAKE437_H
+#include <stdarg.h>
#include <SDL.h>
#include <fake437/types.h>
#include <fake437/primitive.h>
#include <fake437/surface.h>
-#include <fake437/display.h>
#endif
=======================================
--- /trunk/src/libfake437/primitive.c Fri Jan 1 19:05:51 2010
+++ /trunk/src/libfake437/primitive.c Sat Oct 1 16:01:11 2011
@@ -1,5 +1,5 @@
/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
+ * Copyright (C) 2008, 2009, 2010, 2011 Jack Kelly <endga...@gmail.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -83,14 +83,16 @@
return NULL;
}
-void f437_put_char(SDL_Surface* surface, const F437Font* font,
- int x, int y, int ch,
- const SDL_Color* fg, const SDL_Color* bg) {
+void f437_putc(SDL_Surface* surface, const F437Font* font,
+ int x, int y, int scale, int ch,
+ const SDL_Color* fg, const SDL_Color* bg) {
const Uint8* ch_real =
font->chars + (font->char_width * font->char_height * ch);
Uint8 ch_pixel;
int x_pixel;
int y_pixel;
+ int x_scale;
+ int y_scale;
Uint32 bg_color;
Uint32 fg_color;
bg_color = bg == NULL ? 0 : SDL_MapRGB(surface->format,
@@ -98,47 +100,20 @@
fg_color = fg == NULL ? 0 : SDL_MapRGB(surface->format,
fg->r, fg->g, fg->b);
if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface);
- for (y_pixel = 0 ; y_pixel < font->char_height ; y_pixel++) {
- for (x_pixel = 0 ; x_pixel < font->char_width ; x_pixel++) {
- ch_pixel = ch_real[x_pixel + y_pixel * font->char_width];
- if ((ch_pixel > 0 && fg == NULL) ||
- (ch_pixel == 0 && bg == NULL)) continue;
- putpixel(surface, x_pixel + x, y_pixel + y,
- ch_pixel > 0 ? fg_color : bg_color);
+ for (y_pixel = 0; y_pixel < font->char_height; y_pixel++) {
+ for (y_scale = 0; y_scale < scale; y_scale++) {
+ for (x_pixel = 0; x_pixel < font->char_width; x_pixel++) {
+ for (x_scale = 0; x_scale < scale; x_scale++) {
+ ch_pixel = ch_real[x_pixel + y_pixel * font->char_width];
+ if ((ch_pixel > 0 && fg == NULL) ||
+ (ch_pixel == 0 && bg == NULL)) continue;
+ putpixel(surface,
+ (x_pixel * scale) + x + x_scale,
+ (y_pixel * scale) + y + y_scale,
+ ch_pixel > 0 ? fg_color : bg_color);
+ }
+ }
}
}
if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);
}
-
-void f437_put_rect(SDL_Surface* surface, const F437Font* font,
- int x, int y, int width, int height,
- int ch, const SDL_Color* fg, const SDL_Color* bg) {
- int x_char;
- int y_char;
- assert(width >= 0);
- assert(height >= 0);
- if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface);
- for (y_char = 0 ; y_char < height ; y_char++) {
- for (x_char = 0 ; x_char < width ; x_char++) {
- f437_put_char(surface, font,
- x + x_char * font->char_width,
- y + y_char * font->char_height,
- ch, fg, bg);
- }
- }
- if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);
-}
-
-void f437_put_string(SDL_Surface* surface, const F437Font *font,
- int x, int y, const char* string,
- const SDL_Color* fg, const SDL_Color* bg) {
- const char* c;
- int i = 0;
- if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface);
- for (c = string ; *c != '\0' ; c++, i++) {
- f437_put_char(surface, font,
- x + i * font->char_width,
- y, *c, fg, bg);
- }
- if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);
-}
=======================================
--- /trunk/src/libfake437/surface.c Fri Jan 1 19:05:51 2010
+++ /trunk/src/libfake437/surface.c Sat Oct 1 16:01:11 2011
@@ -1,5 +1,5 @@
/* libfake437 - a library for the rendering of code page 437 `graphics'
- * Copyright (C) 2008, 2009, 2010 Jack Kelly <endga...@gmail.com>
+ * Copyright (C) 2008, 2009, 2010, 2011 Jack Kelly <endga...@gmail.com>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -23,23 +23,30 @@
#include "fake437/primitive.h"
#include "fake437/surface.h"
-F437Surface* f437_surface_new(SDL_Surface* surface, const F437Font* font) {
- F437Surface* result = f437_surface_try_new(surface, font);
+F437Surface* f437_surface_new(SDL_Surface* surface,
+ const F437Font* font,
+ int scale) {
+ F437Surface* result = f437_surface_try_new(surface, font, scale);
if (result == NULL) abort();
return result;
}
-F437Surface* f437_surface_try_new(SDL_Surface* surface, const F437Font*
font) {
+F437Surface* f437_surface_try_new(SDL_Surface* surface,
+ const F437Font* font,
+ int scale) {
F437Surface* result;
assert(surface != NULL);
result = malloc(sizeof(*result));
if (result == NULL) return NULL;
result->surface = surface;
result->font = font;
- result->left = (surface->w % font->char_width) / 2;
- result->top = (surface->h % font->char_height) / 2;
- result->width = surface->w / font->char_width;
- result->height = surface->h / font->char_height;
+ result->scale = scale;
+ result->left = (surface->w % (font->char_width * scale)) / 2;
+ result->top = (surface->h % (font->char_height * scale)) / 2;
+ result->width = surface->w / (font->char_width * scale);
+ result->height = surface->h / (font->char_height * scale);
+ result->cursor_x = result->cursor_y = 0;
+ result->fg = result->bg = NULL;
return result;
}
@@ -51,43 +58,49 @@
return result;
}
-void f437_surface_put_char(F437Surface* surface, int left, int top, int ch,
- const SDL_Color* fg, const SDL_Color* bg) {
+void f437_surface_putc(F437Surface* surface, int ch) {
assert(surface != NULL);
assert(surface->surface != NULL);
- assert(left < surface->width);
- assert(top < surface->height);
- f437_put_char(surface->surface, surface->font,
- surface->left + surface->font->char_width * left,
- surface->top + surface->font->char_height * top,
- ch, fg, bg);
+
+ f437_putc(surface->surface, surface->font,
+ surface->left + (surface->font->char_width
+ * surface->cursor_x
+ * surface->scale),
+ surface->top + (surface->font->char_height
+ * surface->cursor_y
+ * surface->scale),
+ surface->scale,
+ ch, surface->fg, surface->bg);
+ surface->cursor_x++;
+ if (surface->cursor_x == surface->width) {
+ surface->cursor_x = 0;
+ surface->cursor_y = (surface->cursor_y + 1) % surface->height;
+ }
}
-void f437_surface_put_rect(F437Surface* surface, int left, int top,
- int width, int height, int ch,
- const SDL_Color* fg, const SDL_Color* bg) {
+void f437_surface_puts(F437Surface* surface, const char* str) {
+ while (*str != '\0') f437_surface_putc(surface, *str++);
+}
+
+void f437_surface_printf(F437Surface* surface, const char* format, ...);
+void f437_surface_nprintf(F437Surface* surface, int n, const char*
format, ...);
+
+void f437_surface_fg(F437Surface* surface, const SDL_Color* fg) {
assert(surface != NULL);
- assert(surface->surface != NULL);
- assert(width >= 0);
- assert(height >= 0);
- assert(left + width <= surface->width);
- assert(top + height <= surface->height);
- f437_put_rect(surface->surface, surface->font,
- surface->left + surface->font->char_width * left,
- surface->top + surface->font->char_height * top,
- width, height, ch, fg, bg);
+ surface->fg = fg;
}
-void f437_surface_put_string(F437Surface *surface, int left, int top,
- const char *string,
- const SDL_Color* fg, const SDL_Color* bg) {
+void f437_surface_bg(F437Surface* surface, const SDL_Color* bg) {
assert(surface != NULL);
- assert(surface->surface != NULL);
- assert(left >= 0);
- assert(top >= 0);
- assert(top < surface->width);
- f437_put_string(surface->surface, surface->font,
- surface->left + surface->font->char_width * left,
- surface->top + surface->font->char_height * top,
- string, fg, bg);
-}
+ surface->bg = bg;
+}
+
+void f437_surface_goto_xy(F437Surface* surface, int x, int y) {
+ assert(surface != NULL);
+ assert(x >= 0);
+ assert(x < surface->width);
+ assert(y >= 0);
+ assert(y < surface->height);
+ surface->cursor_x = x;
+ surface->cursor_y = y;
+}